C語言實驗——刪除指定字元 (sdut oj)
阿新 • • 發佈:2019-02-15
C語言實驗——刪除指定字元
Time Limit: 1000MS Memory Limit: 65536KBProblem Description
從鍵盤輸入一個字串給str和一個字元給c,刪除str中的所有字元c並輸出刪除後的字串str。Input
第一行是一個字串,不超過100個字元;第二行是一個字元。
Output
刪除指定字元後的字串。Example Input
sdf$$$sdf$$ $
Example Output
sdfsdf
Hint
Author
參考程式碼
#include<stdio.h> #include<string.h> int main() { char str[100],i,c; gets(str); scanf("%c",&c); for(i = 0; i < strlen(str); i++) { if(str[i] != c) printf("%c",str[i]); } return 0; }