标签:
Description
Input
Output
Output "YES" if the message on the first line of the input file could be the result of encrypting the message on the second line, or "NO" in the other case.
Sample Input
JWPUDJSTVP VICTORIOUS
Sample Output
YES
Source
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int data1[26]={ 6 0 7 }; 8 int data2[26]={ 9 0 10 }; 11 int main(int argc, char *argv[]) 12 { 13 char str[110]; 14 char ori[110]; 15 scanf("%s",str); 16 scanf("%s",ori); 17 for(int i=0;str[i]!=‘\0‘;i++) 18 { 19 int pt=str[i]-‘A‘; 20 data1[pt]++; 21 } 22 for(int i=0;ori[i]!=‘\0‘;i++) 23 { 24 int pt=ori[i]-‘A‘; 25 data2[pt]++; 26 } 27 sort(data1,data1+26); 28 sort(data2,data2+26); 29 bool flag=true; 30 for(int i=0;i<26;i++) 31 { 32 if(data1[i]!=data2[i]) 33 { 34 flag=false; 35 break; 36 } 37 } 38 if(flag) 39 printf("YES\n"); 40 else 41 printf("NO\n"); 42 return 0; 43 }
标签:
原文地址:http://www.cnblogs.com/GoFly/p/4250868.html