Supplementary Experiment 5

/ * 
Assume the input string contains only letters and an asterisk. 
Write a function to achieve: 
in addition to the string leading and trailing asterisk, * will delete all other numbers in the string. 

When writing a function, not use string functions C language provides. 
For example, if the string to the contents **** A * BC * DEF * G ******* 
After removal, the contents of the string should be ABCDEFG ****** **** 
* / 

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
void Fun (char * A) { 
	/ ** ****** ERROR / 
	int I = 0; 
	char * = T A, A * = F; 
	char * Q = A; 

	the while (* T) 
		T ++; 
	T--; 

	the while (* T == '*') 
		T--; 

	the while (* F == '*') 
		F ++; 
	/ *** *** ERROR / 
	the while (Q <F) { 
		A [I] = * Q; 
		Q ++; 
		I ++; 
	}  
	the while (Q <T) {
		/ ** *** ERROR /
		if (*q != '*') {
			a[i] = *q;
			i++;
		}
		q++;
	}

	while (*q) {
		a[i] = *q;
		i++;
		q++;
	}
	/**ERROR**/
	a[i] = '\0';
}
int main() {
	char s[81];
	printf("Entre a string:\n");
	gets_s(s);
	/**ERROR**/
	fun(s);
	printf("The sting after deleted:\n");
	puts(s);

	system("pause");
	return 0;
}

  

Guess you like

Origin www.cnblogs.com/dzp2001/p/12048698.html