-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassumingJoke.c
67 lines (56 loc) · 1.2 KB
/
assumingJoke.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<stdio.h>
#include<string.h>
int main(){
char str1[101];
char str2[101];
char str[101];
scanf("%s %s %s",str1,str2,str);
char out[201];
strcpy(out, str1);
strcat(out, str2);
int n = strlen(out);
int uniqChar[201], index= 0;
for(int i = 0; i < n; i++){
int isUniqe = 1;
for(int j = 0; j < i; j++){
if(i == j){
continue;
}
if(out[i] == out[j]){
isUniqe = 0;
break;
}
}
if(isUniqe){
uniqChar[index] = out[i];
index++;
}
}
int answer = 1;
for(int i = 0; i < index; i++){
int ch = uniqChar[i], freq1=0, freq2=0;
for(int j = 0; j < n; j++){
if(ch == str[j]){
freq1 += 1;
}
}
for(int j = 0; j < n; j++){
if(ch == out[j]){
freq2 += 1;
}
}
if(freq1 != freq2){
answer = 0;
break;
}
}
if(strlen(out) != strlen(str)){
answer = 0;
}
if(answer){
printf("YES");
}else{
printf("NO");
}
return 0;
}