USACO section1.2 Name That Number 命名那个数字

题目:http://www.wzoi.org/usaco/11%5C206.asp

坑爹的文件输入啊!!!!!!!

View Code
/*
ID: qiufeih1
PROG: namenum
LANG: C++
*/


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cctype>
#include <cstring>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <algorithm>

using namespace std;
//Constant Declaration
/*
--------------------------*/
//#define LL long long
#define LL __int64
const int M=22;
const int INF=1<<30;
const double EPS = 1e-11;
const double PI = acos(-1.0);
/*--------------------------*/
// some essential funtion
/*
----------------------------------*/
void Swap(int &a,int &b){ int t=a;a=b;b=t; }
int Max(int a,int b){ return a>b?a:b; }
int Min(int a,int b){ return a<b?a:b; }
int Gcd(int a,int b){ while(b){b ^= a ^=b ^= a %= b;} return a; }
/*----------------------------------*/
//for (i = 0; i < n; i++)
/*
----------------------------------*/



char F(char c)
{
if (c == 'A' || c == 'B' || c == 'C')
{
return '2';
}

if (c == 'D' || c == 'E' || c == 'F')
{
return '3';
}

if (c == 'G' || c == 'H' || c == 'I')
{
return '4';
}

if (c == 'J' || c == 'K' || c == 'L')
{
return '5';
}

if (c == 'M' || c == 'N' || c == 'O')
{
return '6';
}

if (c == 'P' || c == 'R' || c == 'S')
{
return '7';
}

if (c == 'T' || c == 'U' || c == 'V')
{
return '8';
}

if (c == 'W' || c == 'X' || c == 'Y')
{
return '9';
}
}


int main()
{
//FILE *fin = fopen ("transform.in", "r");
// FILE *fout = fopen ("transform.out", "w");
freopen("namenum.in","r",stdin);
freopen("namenum.out","w",stdout);
//int t, case1 = 0;
//scanf("%d", &t);
//int n, m;
int i, j, k;
int count;
int flag;
char find[30], c[30];
int l1, l2;

//fscanf(fin, "%d", &n);
//fstream fin ("dict.txt", ios::in);
scanf("%s", c);
l1 = strlen(c);
freopen("dict.txt","r",stdin);
count = 0;
while (scanf("%s", find) != EOF)
{
l2 = strlen(find);
if (l1 == l2)
{
flag = 0;
for (i = 0; i < l1; i++)
{
if (c[i] != F(find[i]))
{
flag = 1;
}
}
if (flag == 0)
{
printf("%s\n", find);
count = 1;
}
}
}
if (count == 0)
{
puts("NONE");
}

return 0;
}



原文地址:https://www.cnblogs.com/qiufeihai/p/2421907.html