本题要求编写程序,顺序输出给定字符串中所出现过的大写英文字母,每个字母只输出一遍;若无大写英文字母则输出“Not Found”。
输入格式:
输入为一个以回车结束的字符串(少于80个字符)。
输出格式:
按照输入的顺序在一行中输出所出现过的大写英文字母,每个字母只输出一遍。若无大写英文字母则输出“Not Found”。
输入样例1:
FONTNAME and FILENAME
结尾无空行
输出样例1:
FONTAMEIL
结尾无空行
我的代码:
#include<stdio.h>
#include<string.h>
int main(){
int i,j,len,flag=0,cnt=0;
char str[81];
char ch;
while((ch=getchar())!='\n'){
if(ch>='A'&& ch<='Z'){
flag = 1;
for(i=0;i<cnt;i++){
if(str[i]==ch)
break;
}
if(i==cnt)
str[cnt++]=ch;
}
}
str[cnt]='\0';
if(!flag)
printf("Not Found\n");
else puts(str);
return 0;
}