Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
WA了两次,大伙说的我都注意了,为什么还错呢?求解释!!!#include <iostream> #include <cstring> #include <algorithm> using namespace std; int main() { char message[101],str1[101],str2[101]; while(scanf("%s",str1) != EOF){ scanf("%s",message); int map[101] = {0},i,j,count = 0; int length = strlen(message); if(length != strlen(str1)){ cout << "NO\n"; return 0; } for(i = 0;i < length;i++){ if(message[i] < 'Z') str2[i] = (char)(message[i] + 1); else str2[i] = 'A'; } for(i = 0;i < length;i++) for(j = 0;j < length;j++){ if(str2[i] == str1[j]){ map[count] = j; str1[j] = '0'; count++; break; } } sort(map,map + length); for(i = 1;i < length;i++) if(map[i] == map[i - 1]) break; if(i == length) cout << "YES\n"; else{ cout << "NO\n"; return 0; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator