POJ 1035
来源:互联网 发布:网络舆情信息 编辑:程序博客网 时间:2024/05/01 19:11
注意:不要用string, 否则超时超的怀疑人生,当时还以为是cin>>的问题后来发现是string导致的,血一样的教训,不要因为方便用stirng!!
#include <cstdio>#include <algorithm>#include <iostream>#include <cstring>#include <vector>using namespace std;char s[10010][70];char exist[10010][70];bool cmp1(char *ss1, char * ss2){ int sum = 0; int len = strlen(ss1); for(int i = 0; i < len; i++) { if(ss1[i] != ss2[i]) sum++; if(sum > 1) return 0; } return 1;}bool cmp2(char *ss1, char *ss2){ int l1 = 0, l2 = 0; int sum = 0; int len =strlen(ss2); while(l2 < len) { if(ss1[l1] != ss2[l2]) { sum++; l2++; } else l1++, l2++; if(sum > 1) return 0; } return 1;}int main(){ char ss[70]; int sum = 0; while(scanf("%s", s[sum])) { if(s[sum][0] == '#') { break; } sum++; } while(scanf("%s", ss) != EOF) { if(ss[0] == '#') break; bool correct = 0; bool impossbile = 0; int len = 0; for(int i = 0; i < sum; i++) { if(strcmp(ss,s[i]) == 0) { correct = 1; break; } else if(strlen(ss) == strlen(s[i])) { if(cmp1(ss, s[i])) { impossbile = 1; strcpy(exist[len++], s[i]); } } else if(strlen(ss) == strlen(s[i]) - 1) { if(cmp2(ss, s[i])) { impossbile = 1; strcpy(exist[len++], s[i]); } } else if(strlen(ss) == strlen(s[i]) + 1) { if(cmp2(s[i], ss)) { impossbile = 1; strcpy(exist[len++], s[i]); } } } if(correct == 1) { cout << ss << " is correct" << endl; } else if(impossbile == 1) { cout << ss << ":"; for(int i = 0; i < len; i++) { cout << " " << exist[i]; } cout << endl; } else { cout << ss << ":" << endl; }}return 0;}
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
- Andrew Ng机器学习week4(Neural Networks: Representation)编程习题
- SSH框架整合之使用Domain Modelurl取参数值
- 美图笔试总结
- Java多线程(四)之——Lock
- Rational Grading UVALive
- POJ 1035
- Leetcode 278. First Bad Version
- 自考之路—操作系统阶段小结2
- Lintcode24 LFU Cache solution 题解
- 通过SharePreferences 记住密码
- ZOJ
- HTML
- CentOS下的Hadoop安装教程
- Android Studio logcat 设置 缓存大小 ,增加logcat条数