백준 6996 c++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void input_data(vector<pair<string, string>>& words)
{
string A, B;
int i, n;
cin >> n;
for (i = 0; i < n; i++)
{
cin >> A >> B;
words.push_back({ A, B });
}
return;
}
void find_answer(vector<pair<string, string>>& words)
{
int i;
string A, B;
for (i = 0; i < words.size(); i++)
{
A = words[i].first;
B = words[i].second;
sort(A.begin(), A.end());
sort(B.begin(), B.end());
if (A == B)
{
cout << words[i].first << " & " << words[i].second << " are anagrams.\n";
}
else
{
cout << words[i].first << " & " << words[i].second << " are NOT anagrams.\n";
}
}
return;
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
vector<pair<string, string>> words;
input_data(words);
find_answer(words);
return 0;
}