題目描述:
輸入字符串s和字符c,要求去掉s中所有的c字符,並輸出結果。
- 輸入:
-
測試數據有多組,每組輸入字符串s和字符c。
- 輸出:
-
對於每組輸入,輸出去除c字符後的結果。
- 樣例輸入:
-
heallo a
- 樣例輸出:
-
hello
- 來源:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char *s=(char *)malloc(sizeof(char));
char c;
int len,i;
while(scanf("%s",s)!=EOF)
{
scanf("%c",&c);
c=getchar();
len=strlen(s);
for(i=0;i<len;i++)
{
if(s[i]!=c)
printf("%c",s[i]);
}
printf("\n");
}
return 0;
}
/**************************************************************
Problem: 1049
Language: C
Result: Accepted
Time:0 ms
Memory:912 kb
****************************************************************/