输出出现过的大写英文字母
描述
输入一行字符(不超过100个字符),按次序输出出现过的大写字母。
输入
输入一行字符串(不超过100字符)。
输出
将结果输出到一行中,每个字母后面带一个空格。
输入样例 1
FONTNAME and FILENAME
输出样例 1
F O N T A M E I L
提示
HINT 时间限制:200ms 内存限制:64MB
#include<bits/stdc++.h>
using namespace std;
int main() {
char input[101];
char output[27];
int count = 0;
fgets(input, sizeof(input), stdin);
for (int i = 0; input[i] != '\0'; i++) {
if (isupper(input[i])) {
int already_present = 0;
for (int j = 0; j < count; j++) {
if (output[j] == input[i]) {
already_present = 1;
break;
}
}
if (!already_present) {
output[count] = input[i];
count++;
}
}
}
for (int i = 0; i < count; i++) {
printf("%c ", output[i]);
}
printf("\n");
return 0;
}
316

被折叠的 条评论
为什么被折叠?



