思路
考虑直接使用 map 将每一个字符映射,如果该字符出现过,那么就把对应位置设成 ,最后从 A 到 Z 遍历 个字符,输出对应位置为 的字母即可。
代码
#include<bits/stdc++.h>
using namespace std;
map<char,bool>vis;//标记数组
int n;
char x;
bool flag;
int main()
{
cin>>n;
while(n--)
{
cin>>x;
vis[x]=1;//标记出现过
}
for (char i='A';i<='Z';i++)
if(!vis[i])//没有出现
{
cout<<i;
flag=1;
}
if(!flag)//所有字母均未出现
cout<<-1;
}