No older revisions available
No older revisions available
Map연습문제 ¶
~cpp
#include <vector>
#include <map>
#include <iostream>
#include<fstream>
using namespace std;
struct student
{
string name;
int score;
};
int main()
{
map<char, char> rule1;
map<char, char> rule2;
map<char, char> rule3;
rule1['b']='1'; rule2['1']='z'; rule3['z']='a';
rule1[' ']='2'; rule2['2']='x'; rule3['x']='b';
rule1['z']='3'; rule2['3']=' '; rule3[' ']='c';
rule1['a']='4'; rule2['4']='y'; rule3['y']='d';
rule1['y']='5'; rule2['5']='a'; rule3['a']='e';
rule1['x']='6'; rule2['6']='w'; rule3['w']='f';
rule1['i']='7'; rule2['7']='v'; rule3['v']='g';
rule1['h']='8'; rule2['8']='u'; rule3['u']='h';
rule1['g']='9'; rule2['9']='b'; rule3['b']='i';
rule1['\n']='0'; rule2['0']='t'; rule3['t']='j';
rule1['c']='!'; rule2['!']='s'; rule3['s']='k';
rule1['f']='@'; rule2['@']='c'; rule3['c']='l';
rule1['e']='#'; rule2['#']='r'; rule3['r']='m';
rule1['d']='$'; rule2['$']='o'; rule3['o']='n';
rule1['w']='%'; rule2['%']='d'; rule3['d']='o';
rule1['u']='^'; rule2['^']='p'; rule3['p']='p';
rule1['v']='&'; rule2['&']='e'; rule3['e']='q';
rule1['j']='*'; rule2['*']='q'; rule3['q']='r';
rule1['k']='('; rule2['(']='l'; rule3['l']='s';
rule1['l']=')'; rule2[')']='m'; rule3['m']='t';
rule1['m']='<'; rule2['<']='f'; rule3['f']='u';
rule1['n']='>'; rule2['>']='g'; rule3['g']='v';
rule1['o']='?'; rule2['?']='\n'; rule3['\n']='w';
rule1['p']='{'; rule2['{']='h'; rule3['h']='x';
rule1['t']='}'; rule2['}']='i'; rule3['i']='y';
rule1['s']='='; rule2['=']='j'; rule3['j']='z';
rule1['q']='+'; rule2['+']='k'; rule3['k']='2';
rule1['r']='-'; rule2['-']='n'; rule3['n']='\n';
ifstream fin("input.txt");
char ch;
while(fin.get(ch))
{
cout << rule3[ rule2[ rule1[ch] ] ];
}
cout << endl;
return 0;
}
~cpp
//input.txt
wjgydlrtyffworxjbdzyrsybfwlrobffylryjbkyjrtbdcyyrvmbjlsrkugjglrmdcgdarjbjyftr
~cpp
// ing..
#include <vector>
#include <map>
#include <iostream>
#include<fstream>
using namespace std;
struct student
{
string name;
int score;
};
int main()
{
map<char, char> rule1;
map<char, char> rule2;
map<char, char> rule3;
rule1['b']='1'; rule2['1']='z'; rule3['z']='a';
rule1[' ']='2'; rule2['2']='x'; rule3['x']='b';
rule1['z']='3'; rule2['3']=' '; rule3[' ']='c';
rule1['a']='4'; rule2['4']='y'; rule3['y']='d';
rule1['y']='5'; rule2['5']='a'; rule3['a']='e';
rule1['x']='6'; rule2['6']='w'; rule3['w']='f';
rule1['i']='7'; rule2['7']='v'; rule3['v']='g';
rule1['h']='8'; rule2['8']='u'; rule3['u']='h';
rule1['g']='9'; rule2['9']='b'; rule3['b']='i';
rule1['\n']='0'; rule2['0']='t'; rule3['t']='j';
rule1['c']='!'; rule2['!']='s'; rule3['s']='k';
rule1['f']='@'; rule2['@']='c'; rule3['c']='l';
rule1['e']='#'; rule2['#']='r'; rule3['r']='m';
rule1['d']='$'; rule2['$']='o'; rule3['o']='n';
rule1['w']='%'; rule2['%']='d'; rule3['d']='o';
rule1['u']='^'; rule2['^']='p'; rule3['p']='p';
rule1['v']='&'; rule2['&']='e'; rule3['e']='q';
rule1['j']='*'; rule2['*']='q'; rule3['q']='r';
rule1['k']='('; rule2['(']='l'; rule3['l']='s';
rule1['l']=')'; rule2[')']='m'; rule3['m']='t';
rule1['m']='<'; rule2['<']='f'; rule3['f']='u';
rule1['n']='>'; rule2['>']='g'; rule3['g']='v';
rule1['o']='?'; rule2['?']='\n'; rule3['\n']='w';
rule1['p']='{'; rule2['{']='h'; rule3['h']='x';
rule1['t']='}'; rule2['}']='i'; rule3['i']='y';
rule1['s']='='; rule2['=']='j'; rule3['j']='z';
rule1['q']='+'; rule2['+']='k'; rule3['k']='2';
rule1['r']='-'; rule2['-']='n'; rule3['n']='\n';
vector<map> vec;
vec.push_back(rule1);
vec.push_back(rule2);
vec.push_back(rule3);
ifstream fin("input.txt");
char ch,temp;
while(fin.get(ch))
{
temp=ch;
for(map::iterator i=vec.begin(); i< vec.end() ;i++)
{
temp = (i*)[temp];
}
}
cout << endl;
return 0;
}