fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7. //IN;
  8. string A, B;
  9. int case_i=0;
  10. while (1)
  11. {
  12. cin>>A>>B;
  13. if (A=="END" && B=="END") break;
  14. case_i++;
  15. //OUT;
  16. int arrA[128], arrB[128];
  17. for (int i=32; i<=126; i++)
  18. {
  19. arrA[i]=0;
  20. arrB[i]=0;
  21. }
  22. int lenA=A.length();
  23. int lenB=B.length();
  24. for (int i=0; i<lenA; i++)
  25. {
  26. int cs=A[i]-0;
  27. arrA[cs]++;
  28. }
  29. for (int i=0; i<lenB; i++)
  30. {
  31. int cs=B[i]-0;
  32. arrB[cs]++;
  33. }
  34. int kt=1;
  35. for (int i=97; i<=122; i++)
  36. {
  37. if (arrA[i]!=arrB[i])
  38. {
  39. kt=0;
  40. break;
  41. }
  42. }
  43. if (kt==1) cout<<"Case "<<case_i<<": same"<<endl;
  44. else cout<<"Case "<<case_i<<": different"<<endl;
  45. }
  46.  
  47. return 0;
  48. }
Success #stdin #stdout 0s 15240KB
stdin
testing 
intestg 
abc 
aabbbcccc 
abcabcbcc 
aabbbcccc 
abc 
xyz 
END 
END
stdout
Case 1: same
Case 2: different
Case 3: same
Case 4: different