【水题】USACO Name That Number

[size=small]进入USACO要注册才能看题:[/size] [url]http://train.usaco.org/usacogate[/url]

[size=medium]题目:【翻译版、是别处的网站】[url]http://www.wzoi.org/usaco/11%5C206.asp[/url]

[color=blue]SAMPLE INPUT (file namenum.in)
4734

SAMPLE OUTPUT (file namenum.out)
GREG[/color]

又被水题虐了!
[/size]


/*
ID: 1006100071
PROG: namenum
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <set>
//#include <map>
#include <queue>
#include <utility>
#include <iomanip>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h>
using namespace std;

struct str{
char num[30], origin[30];
}x[5005];

int main()
{
int k = 0, len, i;
bool flag = false;
char s[30], map[30] = {"222333444555666707788899900"}; //之前没把无映射字母设置为0,错2次
freopen ("namenum.in", "r", stdin);
freopen ("namenum.out", "w", stdout);
fstream fin ("dict.txt", ios::in);
while (fin.getline (x[k].origin, 25))
{
len = strlen (x[k].origin);
for (i = 0; i < len; i++)
x[k].num[i] = map[x[k].origin[i]-'A'];
x[k].num[len] = 0;
k++;
}
scanf ("%s", s);
for (i = 0; i < k; i++)
if (!strcmp (s, x[i].num))
printf ("%s\n", x[i].origin), flag = true;
if (!flag)
puts ("NONE"); //一开始竟然漏掉这句!错一次!
return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值