poj 1035
来源:互联网 发布:java 静态方法调用 编辑:程序博客网 时间:2024/05/01 09:43
一开始没审题,直接用map,wa
后来看见字典序,没理解意思,又wa
后来才理解是输入的字典序。。
上去一发,tle
后来发现忘了break;
代码如下
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int main(){char a[10005][16];char temp[16];int num=0,cnt=0;while(scanf("%s",a[num])){if(a[num][0]!='#') {num++; continue;}num--;break;}while(scanf("%s",temp)){if(temp[0]!='#'){int len=strlen(temp);int flag=0; //0表示没找到; for(int i=0;i<=num;i++){int le=strlen(a[i]);if(le==len) {int num=0;for(int j=0;j<len;j++){if(a[i][j]==temp[j]) num++;} if(num==len) {flag=1;printf("%s is correct\n",temp);break;}}}if(flag==1) continue;printf("%s:",temp);for(int i=0;i<=num;i++){int le=strlen(a[i]);if(le==len) {int num=0;for(int j=0;j<len;j++){if(temp[j]==a[i][j]) num++;}if(num==len-1) printf(" %s",a[i]);}if(le==len-1){int cnt=0;for(int j=0;j<len;j++){if(temp[j]==a[i][cnt]) cnt++;}if(cnt==le) printf(" %s",a[i]);}if(le==len+1){int cnt=0;for(int j=0;j<le;j++){if(a[i][j]==temp[cnt]) {cnt++;}} if(cnt==len) printf(" %s",a[i]);}}printf("\n"); continue;}break;}}
阅读全文
0 0
- POJ 1035
- Poj 1035
- POJ 1035
- poj 1035
- poj 1035
- poj 1035
- poj 1035
- POJ 1035
- poj.1035
- poj-1035
- poj 1035
- poj 1035
- poj 1035
- POJ 1035
- POJ 1035
- poj 1035
- poj-1035-Spell checker
- poj 1035 Spell checker
- 高并发网站解决方法
- leetcode292. Nim Game
- session与application生命周期的区别
- 类、对象、属性、方法
- git使用和常见问题处理
- poj 1035
- 市场走势暴露主力意图!这类股或有大机会
- libpcap详解
- TCP 相关大神博客
- Windows常见问题及解决
- TensorFlow 基础小记
- 自定义View----自定义轮播图
- DNA排序
- Bits*