#include <stdio.h>
#define PI_PROJECT 1314
int main()
{
char str[PI_PROJECT], str1[PI_PROJECT];
int i = 0, j = 0, m = 0;
gets(str);//不建议使用scanf函数,因为scanf函数遇见空格键会停止读取字符串。
while (str[i] != '\0')//找出字符数组中的大写字母
{
if ('A' <= str[i]&&str[i] <= 'Z')
{
str1[j++] = str[i];
}
i++;
}
for (m = 0; m < j; m++)//删除字符数组中重复的大写字母
{
int flag = 1;
for (i = 0; i < m; i++)
{
if (str1[m] == str1[i])
{
flag = 0;
}
}
if (flag == 1)
{
printf("%c", str1[m]);
}
}
return 0;
}
输入1个字符串,输出其中所出现过的大写英文字母(可不按输入顺序输出大写字母),但不可重复出现。如运行时输入字符串“FONTNAME and FILENAME”,则应输出”FONTAMEIL”。
最新推荐文章于 2023-04-02 21:11:21 发布