1. 1st Source ¶
#include <map>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
class Anagram
{
private:
typedef map< string, map<char, int> >::iterator MSMCII;
typedef map< char, int > MCI;
map< string, map<char, int> > _anagramTable;
public:
void CalWhatAnagram(const string& str)
{
MCI howManyEachAlphabet;
for(int i = 0 ; i < str.size() ; ++i)
howManyEachAlphabet[ str[i] ] += 1;
_anagramTable[str] = howManyEachAlphabet;
}
void Show()
{
while( !_anagramTable.empty() )
{
MCI value = _anagramTable.begin()->second;
for(MSMCII i = _anagramTable.begin() ; i != _anagramTable.end() ; )
{
if(i->second == value)
{
cout << i->first << " ";
_anagramTable.erase(i++);
}
else
{
++i;
}
}
cout << endl;
}
}
};
int main()
{
Anagram anagram;
ifstream fin("input.dat");
string t;
while(!fin.eof())
{
getline(fin, t);
anagram.CalWhatAnagram(t);
}
anagram.Show();
fin.close();
return 0;
}
2. 1st ¶
- 먼 받면, , 는 <벳, 벳 > Pair Pair를 .(--; 뭔 말 )
- , 를 n, 를 m 면, 떤 Pair 는데 (mn) 린. map 는데 (n) 린.
- , 를 n, 를 m 면, 떤 Pair 는데 (mn) 린. map 는데 (n) 린.
- 는 map 를 면, 번 부 돌면 anagram .( 방 는 .)
- 대 . (n*n) 리는 는.
- 대 . (n*n) 리는 는.
- 는 보는... 무 . 리 (n*n) 린 .
4. 2nd Source ¶
~cpp
#include <map>
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
class Anagram
{
private:
typedef map<char, int> MCI;
typedef vector<string> LS;
typedef map< MCI, LS > MALS;
typedef MALS::iterator MALSI;
typedef LS::iterator LSI;
MALS _anagramTable;
MCI CalculateWhatAnagram(const string& str)
{
MCI howManyEachAlphabet;
for(int i = 0 ; i < str.size() ; ++i)
howManyEachAlphabet[ str[i] ] += 1;
return howManyEachAlphabet;
}
public:
void BoundAnagram(char* fileName)
{
ifstream fin(fileName);
string str;
while(!fin.eof())
{
getline(fin, str);
_anagramTable[ CalculateWhatAnagram(str) ].push_back(str);
}
}
void ShowAnagram()
{
for(MALSI i = _anagramTable.begin() ; i != _anagramTable.end() ; ++i)
{
for(LSI j = (i->second).begin() ; j != (i->second).end(); ++j)
{
cout << *j << " ";
}
cout << endl;
}
}
};
int main()
{
Anagram ana;
ana.BoundAnagram("input.dat");
ana.ShowAnagram();
return 0;
}
5. 2nd ¶
- 먼 받는 key : 떤 벳 몇번 map , value : string들 list. 런 .
- 1st 부 대부 먹만.. 번 부 90 먹는 .
- 대 볼, 를 n, 를 m 면, : (mn), : (n) 므 런데 m n보 ~~~~~ . (n) 는?--; 뭔 변 .
6. 2nd ¶
- 뭔 더 방 는.
- 1(2만리) . 더 . 10배 불면..--; 10 리는 .
- 데 10(2만리)만 . --;
- 면 는 보 많 린. "~~~ inputed!" 더 10 리는데, 1 린.
- list를 vector 바 마 6.2 린.










