Description
从字符串中删除指定的字符。
Input
输入有两行,第一行输入一个字符,第二行输入一串字符(最多不超过20个字符)。
Output
输出仅一行,如果有字符被删除,则输出删除指定字符后的字符串。如果没有字符被删除,则输出not found(两单词中间有一空格)。
Sample Input
5
ab5c35adg57c
Sample Output
abc3adg7c
代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char a,b[30],c[30];
int i,j,k=0;
a=getchar();
getchar();//缓冲回车
gets(b);
j=strlen(b);
for(i=0;i<j;i++)
{
if(b[i]!=a)
{
c[k]=b[i];
k++;
}
}
c[k]='\0';
if(strlen(b)!=strlen(c))
puts(c);
else
printf("not found");
return 0;
}