#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
using namespace std;
int main(int argc, char const *argv[])
{
map<char,char > m;
m['A'] = '2';
m['B'] = '2';
m['C'] = '2';
m['D'] = '3';
m['E'] = '3';
m['F'] = '3';
m['G'] = '4';
m['H'] = '4';
m['I'] = '4';
m['J'] = '5';
m['K'] = '5';
m['L'] = '5';
m['M'] = '6';
m['N'] = '6';
m['O'] = '6';
m['P'] = '7';
m['R'] = '7';
m['S'] = '7';
m['T'] = '8';
m['U'] = '8';
m['V'] = '8';
m['W'] = '9';
m['X'] = '9';
m['Y'] = '9';
string lines;
ifstream in("name.txt");
cout<<"number is ?"<<endl;
string number;
cin>>number;
if(in)
{
while(getline(in,lines))
{
int i;
if(lines.length() == number.length())
{
int count = 0;
for(i=0;i<lines.length();i++)
{
if(number[i] == m[lines[i]])
{
count++;
}
else
break;
}
if(count == (lines.length()))
cout<<lines;
}
else
continue;
}
}
else
{
cout<<"open file failed!"<<endl;
}
return 0;
}
Name That Number 命名那个数字
最新推荐文章于 2020-03-31 21:21:56 发布