Quick actions

cmd+k|ctrl+k

Navigation

Languages

16. 아나그램

Snippet info

Language

C

Visibility

public

Author

kim112mgxld

Created

2020-09-23T07:06:52Z

Updated

2020-09-23T08:27:02Z

#include <stdio.h>
#include <stdlib.h>
#define MAX 100

int main(void) {
    char str1[MAX], str2[MAX];
    int check1[53] = {0}, check2[53] = {0};
    
    scanf("%s", str1);
    scanf("%s", str2);
    
    for (int i = 0; str1[i] != '\0'; i++) {
        // Str 1
        if (str1[i] >= 65 && str1[i] <= 90) {
            check1[str1[i] - 65]++;
        } else {
            check1[str1[i] - 71]++;
        }
        
        // Str 2
        if (str2[i] >= 65 && str2[i] <= 90) {
            check2[str2[i] - 65]++;
        } else {
            check2[str2[i] - 71]++;
        }
    }
    
    for (int i = 0; i < 53; i++) {
        if (check1[i] != check2[i]) {
            printf("NO\n");
            
            return 0;
        }
    }
    
    printf("YES\n");
    
    return 0;
}
INFO