Name That Number

Posted wolf940509

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Name That Number相关的知识,希望对你有一定的参考价值。

链接

分析:找出每一个字母对应的数字,然后看字典里面那个与其匹配

技术分享
 1 /*
 2 ID: ****
 3 PROG: namenum
 4 LANG: C++
 5 */
 6 #include<iostream>
 7 #include<fstream>
 8 #include<string.h>
 9  
10 using namespace std;
11  
12 const char alpha[26]={2,2,2,3,3,3,4,4,4,5,5,5, 6,6,6,7,0,7,7,8,8,8,9,9,9,0};
13 string data,tmp,words;
14 bool flag=false;
15  
16 int main(){
17     ifstream fin("namenum.in");
18     ofstream fout("namenum.out");
19     fin>>data;
20     ifstream tin("dict.txt");
21     while (tin>>words){
22           int l=words.size();
23           tmp="";
24           for (int i=0;i<l;i++) tmp+=alpha[words[i]-65];
25           if (tmp==data) {fout<<words<<endl;flag=true;}
26           }
27     if (!flag) fout<<"NONE"<<endl;
28     return 0;
29 }                                                                                           
View Code

 

以上是关于Name That Number的主要内容,如果未能解决你的问题,请参考以下文章

USACO 1.2Name That Number

Name That Number 命名那个数字(打开文件)

小程序

报错“Field pet in XXX.HelloController required a bean of type ‘XXX.Pet‘ that could not be found.“(代码片段

LeetCode(数据库)- Number of Accounts That Did Not Stream

find the leftmost column that has number 1