-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6996.cpp
More file actions
58 lines (41 loc) · 1.23 KB
/
6996.cpp
File metadata and controls
58 lines (41 loc) · 1.23 KB
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
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cstring>
#include <string>
using namespace std;
int dp[1001];
int main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int T;
cin >> T;
while (T--) {
vector<char>a;
vector<char>b;
string tempa, tempb;
cin >> tempa >> tempb;
for (int i = 0; i < tempa.size(); i++)a.push_back(tempa[i]);
for (int i = 0; i < tempb.size(); i++)b.push_back(tempb[i]);
sort(a.begin(),a.end());
sort(b.begin(), b.end());
if (a.size() != b.size()) {
cout << tempa << " & " << tempb << " are NOT anagrams." << endl;
continue;
}
else {
int flag = 0;
for (int i = 0; i < a.size(); i++) {
if (a[i] != b[i]) {
cout << tempa << " & " << tempb << " are NOT anagrams." << endl;
flag = 1;
break;
}
}
if (flag)continue;
else {
cout << tempa << " & " << tempb << " are anagrams." << endl;
}
}
}
}