欢迎使用CSDN-markdown编辑器

来源:互联网 发布:巨人网络纪学锋 编辑:程序博客网 时间:2024/06/08 02:36

/*
ID: your_id_here
PROG: namenum
LANG: C++11
*/

include

include

include

using namespace std;

string trans(string in) {
string str = in;
for (int i = 0; i < str.size(); i++) {
char &item = str[i];
switch (item) {
case ‘A’: case ‘B’: case ‘C’: item = ‘2’; break;
case ‘D’: case ‘E’: case ‘F’: item = ‘3’; break;
case ‘G’: case ‘H’: case ‘I’: item = ‘4’; break;
case ‘J’: case ‘K’: case ‘L’: item = ‘5’; break;
case ‘M’: case ‘N’: case ‘O’: item = ‘6’; break;
case ‘P’: case ‘R’: case ‘S’: item = ‘7’; break;
case ‘T’: case ‘U’: case ‘V’: item = ‘8’; break;
case ‘W’: case ‘X’: case ‘Y’: item = ‘9’; break;
}
}
return str;
}

int main() {
ofstream fout (“namenum.out”);
ifstream fin (“namenum.in”);
ifstream dict (“dict.txt”);
int n = 0;
string row;
fin >> row;
string names;
while (dict >> names) {
string name = trans(names);
if (name == row) {
fout << names << endl;
n++;
}
}
if (n == 0)
fout << “NONE” << endl;
return 0;
}

0 0
原创粉丝点击