Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7. char word[2][200000];
  8. int n;
  9. int i, j, k, l;
  10. int len[2];
  11. char temp;
  12. scanf("%d", &n);
  13. for ( i = 0; i < n; i++){
  14. scanf("%s%s", word[0], word[1]);
  15. for ( j = 0; j < 2; j++)
  16. for ( k = 0; strcmp(word[j] + k, "\0"); k++)
  17. if ( !isalpha(word[j][k])){
  18. strcpy( word[j] + k, word[j] + k + 1);
  19. k--;
  20. }
  21. len[0] = strlen(word[0]);
  22. len[1] = strlen(word[1]);
  23. if ( len[0] != len[1]){
  24. printf("no\n");
  25. continue;
  26. }
  27. for ( j = 0; j < len[0]; j++){
  28. word[0][j] = tolower(word[0][j]);
  29. word[1][j] = tolower(word[1][j]);
  30. }
  31. for ( j = 0; j < 2; j++)
  32. for (k = len[j] - 2; k >=0 ; k--)
  33. for ( l = 0; l <= k; l++)
  34. if ( word[j][l] > word[j][l + 1]){
  35. temp = word[j][l];
  36. word[j][l] = word[j][l + 1];
  37. word[j][l + 1] = temp;
  38. }
  39. printf("%s\n", (!strcmp(word[0], word[1])) ? "yes" : "no");
  40. }
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement