【C++】OJ458

#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<algorithm>
#include<iterator>
using namespace std;
class word{
public:
	char seem;
	char real;
	word(char a,char b){seem = a;real = b;};
};
int main(){
	word a[] = {word('j','c'),word('k','d'),word('p','i'),word('1','*'),word('l','e'),
	word('{','t'),word('h','a'),word('y','r'),word('n','g'),word('x','q'),word('|','u'),
	word('w','p'),word('t','m'),word('u','n'),word('v','o'),word('5','.'),word('z','s'),
	word('o','h'),word('r','k'),word('m','f'),word('s','l'),word('i','b')};
	vector<word> b(a,a+22);
	vector<char> d(a->seem,(a+22)->seem);
	vector<word>::iterator it;
	string c;
	ifstream in;
	in.open("D:\\8.txt");
	while(in >> c){
		for(int i = 0;i<c.length();i++){
			bool isup = false;
			bool find = false;
			if(isupper(c[i])==true){
			    c[i] = (char)tolower(c[i]);
				isup = true;
			}
			    for(it = b.begin();it!=b.end();it++){
				    if((it->seem)==c[i]){
						find = true;
					    if(isup==true)
					        cout<< (char)toupper(it->real);
					    else
						    cout<< it->real;
					    break;
				    }
			    }
				if(find==false)
					cout <<" ";
		}
	}
}

点赞