Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- int main()
- {
- char word[2][200000];
- int n;
- int i, j, k, l;
- int len[2];
- char temp;
- scanf("%d", &n);
- for ( i = 0; i < n; i++){
- scanf("%s%s", word[0], word[1]);
- for ( j = 0; j < 2; j++)
- for ( k = 0; strcmp(word[j] + k, "\0"); k++)
- if ( !isalpha(word[j][k])){
- strcpy( word[j] + k, word[j] + k + 1);
- k--;
- }
- len[0] = strlen(word[0]);
- len[1] = strlen(word[1]);
- if ( len[0] != len[1]){
- printf("no\n");
- continue;
- }
- for ( j = 0; j < len[0]; j++){
- word[0][j] = tolower(word[0][j]);
- word[1][j] = tolower(word[1][j]);
- }
- for ( j = 0; j < 2; j++)
- for (k = len[j] - 2; k >=0 ; k--)
- for ( l = 0; l <= k; l++)
- if ( word[j][l] > word[j][l + 1]){
- temp = word[j][l];
- word[j][l] = word[j][l + 1];
- word[j][l + 1] = temp;
- }
- printf("%s\n", (!strcmp(word[0], word[1])) ? "yes" : "no");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement