fork download
  1. #include<cstdio>
  2. #include<iostream>
  3. #include<string>
  4. #include<algorithm>
  5. #include<vector>
  6. #include<numeric>
  7. using namespace std;
  8. int main()
  9. {
  10. int t,i,j;
  11. cin>>t;
  12. string resp;
  13. vector<string>words;
  14. vector<string>words_backup;
  15. while(t--)
  16. {
  17. cin>>resp;
  18. words.push_back(resp);
  19. }
  20. words_backup=words;
  21. /* for(int i=0; i<words_backup.size();i++)
  22.   {cout<<words_backup[i]<<":)\n";}
  23.   */
  24. for(int i=0; i<words.size();i++)
  25. {
  26. sort(words[i].begin(),words[i].end());
  27. }
  28. sort(words.begin(),words.end());
  29. for(i=0,j=1; i<words.size(),j<words.size();i++,j++)
  30. {
  31.  
  32. if(words[i]==words[j])
  33. {
  34. cout<<"ANAGRAM:";
  35. cout<<words[i]<<" "<<words[j]<<endl;
  36. }
  37. }
  38.  
  39. /* for(int i=0; i<words.size();i++)
  40.   {cout<<words[i]<<"\n";}
  41.   */
  42. system("pause");
  43. return 0;
  44. }
  45.  
Runtime error #stdin #stdout 4.12s 266240KB
stdin
Standard input is empty
stdout
Standard output is empty