题目 http://acm.hdu.edu.cn/showproblem.php?pid=1287
一开始源码26行写的是
if(*it ^ c <'A' || *it ^ c >'Z')
而不是
if((int)(*it ^ c) <'A' || (int)(*it ^ c) >'Z')
一直错误,不要问我为神马,我也不知道为神马要用ASCII码,这是为神马啊。。。
#include<cstdio>
#include<vector>
using namespace std;
int main()
{
int N, num;
vector<int> vec;
//freopen("in.txt", "r", stdin);
while(scanf("%d", &N)==1)
{
vec.clear();
for(int i = 0; i < N; ++i)
{
scanf("%d", &num);
vec.push_back(num);
}
bool flag;
char c;
for(c='A'; c <='Z'; ++c)
{
flag = true;
for(vector<int>::iterator it = vec.begin(); it!=vec.end(); ++it)
{
if((int)(*it ^ c) <'A' || (int)(*it ^ c) >'Z')
{
flag = false;
break;
}
}
if(flag)
{
break;
}
}
for(vector<int>::iterator it = vec.begin(); it!=vec.end(); ++it)
{
printf("%c", *it ^ c);
}
printf("\n");
}
return 0;
}