1391 猜单词啦
来源:互联网 发布:数据分析算什么行业 编辑:程序博客网 时间:2024/06/05 02:11
一个古老的游戏……
给你一个字典,里面包含了N个单词,单词全部由小写字母构成;
现在告诉你猜测过程中知道的情况:
‘a’ a1
‘b’ a2
…
‘z’ a26
分别表示对应字母在该单词中出现了多少次,如果ai=-1表示还不清楚这个字母的情况;
希望你能找到所有可能的单词;
- 输入
第一行包含一个整数N,表示有N个单词;N不超过10,000
以下N行每行包含一个字符串,表示一个单词,不一定是字典序……
第N+2行包含一个整数T,表示有T组数据;
对于每组数据:
一行包含26个整数,即a1~a26;
- 输出
对于每组数据:
输出可能的单词,如果没有可能单词,请输出kao!cheating!
否则依次输出可能单词,每个单词占一行,请按照输入单词的顺序输出单词;
模拟题,用数组保存每个单词中出现的字母,加以判断
#include <stdio.h>#include <string.h>main(){int te,number1,number2; char a[10000][30];int i,j;int count[10000][27];int count1;int b[27];int flag;scanf("%d",&number1);getchar();for(te=0;te<number1;te++){scanf("%s",&a[te]);}memset(count,0,sizeof(count)); for(i=0;i<number1;i++)for(j=0;a[i][j]!='\0';j++){switch(a[i][j]){case 'a':count[i][1]++;break;case 'b':count[i][2]++;break;case 'c':count[i][3]++;break;case 'd':count[i][4]++;break;case 'e':count[i][5]++;break;case 'f':count[i][6]++;break;case 'g':count[i][7]++;break;case 'h':count[i][8]++;break;case 'i':count[i][9]++;break;case 'j':count[i][10]++;break;case 'k':count[i][11]++;break;case 'l':count[i][12]++;break;case 'm':count[i][13]++;break;case 'n':count[i][14]++;break;case 'o':count[i][15]++;break;case 'p':count[i][16]++;break;case 'q':count[i][17]++;break;case 'r':count[i][18]++;break;case 's':count[i][19]++;break;case 't':count[i][20]++;break;case 'u':count[i][21]++;break;case 'v':count[i][22]++;break;case 'w':count[i][23]++;break;case 'x':count[i][24]++;break;case 'y':count[i][25]++;break;case 'z':count[i][26]++;break;}}scanf("%d",&number2);for(te=1;te<=number2;te++){ flag=0;count1=0;for(j=1;j<=26;j++)scanf("%d",&b[j]);for(i=0;i<number1;i++){ count1=0;for(j=1;j<=26;j++){if(b[j]==count[i][j]||b[j]==-1){ count1++;continue;} else break;}if(count1==26){printf("%s\n",a[i]); count1=0;flag=1;}}if(flag==0)printf("kao!cheating!\n");} }
- 1391 猜单词啦
- 猜单词
- 猜单词
- 猜数字啦
- 啦
- 啦
- HDU 1727 Hastiness纯粹的英文单词拼写(就当背英文数字的单词啦)
- 猜单词游戏
- 模拟猜单词游戏
- 【c++】猜单词游戏
- 猜单词的游戏
- Python小游戏 -- 猜单词
- 猜单词游戏
- 单词。。
- 单词
- 单词
- 单词
- 单词:
- 单态模式Singleton
- PNG透明窗体全攻略(控件不透明)
- 给android模拟器安装apk 文件
- 1390 DNA序列
- android体系结构
- 1391 猜单词啦
- JTree學習(一)
- android的一些异常
- 关于解决MyEclipse 的耗内存的办法
- 1392 最长公共子串
- NYOJ 水池数目(BFS)
- 了解Android误区
- 安装android开发环境
- 1395 名字查找