这么一道水题。。WA了数次。。。让姐情何以堪。。
给你两串字符,上面那串是翻译后的,下面那串是需要你翻译的。。把下面文章每个字母第二行对应的翻译成对应的第一行的。。
头两串应该有空格 = =。。。WA了数次。。。
我开始以为只有26个小写字母来着。。。一直WA。。。可见可能什么字母都有 = =。。。
交题的时候忘记删掉freopen。。。WA了几次。。抓狂 = =。。。
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string.h>
#include <queue>
#include <limits.h>
using namespace std;
int to[500];
int main()
{
char str[100];
char wuyu[2][100];
int i,len;
memset(to,-1,sizeof(to));
gets(wuyu[0]);
gets(wuyu[1]);
for(i=0; i<strlen(wuyu[0]); i++)
to[wuyu[0][i]-' '] = wuyu[1][i] -' ';
puts(wuyu[1]);
puts(wuyu[0]);
while( gets(str) )
{
len = strlen(str);
for(i=0; i<len; i++)
{
if( to[str[i]-' '] != -1 )
printf("%c",to[str[i]-' ']+' ');
else
printf("%c",str[i]);
}
putchar('/n');
}
return 0;
}