View Code of Problem 55

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(){

	/*
从键盘输入一个字符串给str和一个字符给c,
删除str中的所有字符c并输出删除后的字符串str。
	*/

	char str[1000];
	gets(str);
	char c ;
	int i = 0 , j =  0 ;
	scanf("%c" , &c);
	for( i = 0 ; i < strlen(str) ; i++){
		if( str[i] != c )
			str[j++] = str[i];
	}
	str[j] = '\0';

	puts(str);


	
	return 0;
}	

Double click to view unformatted code.


Back to problem 55