poj 1035(水题,注意增删时的操作)
Posted 智人心
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了poj 1035(水题,注意增删时的操作)相关的知识,希望对你有一定的参考价值。
#include<iostream> #include<cstring> using namespace std; int main(){ char dict[10005][20],tar[20],tmp[20]; int count,i,j,diff_num; bool flag; count = 0; while(scanf("%s",tmp)==1&&strcmp(tmp,"#")!=0){ strcpy(dict[count++],tmp); } while(scanf("%s",tmp)==1&&strcmp(tmp,"#")!=0){ flag = false; for(i=0;i<count;i++){ if(strcmp(tmp,dict[i])==0){ flag = true; } } if(flag){ printf("%s is correct\\n",tmp); continue; } printf("%s:",tmp); for(i=0;i<count;i++){ if(strlen(tmp)==strlen(dict[i])){ diff_num = 0; for(j=0;j<strlen(tmp);j++){ if(tmp[j]!=dict[i][j]) diff_num++; } if(diff_num==1) printf(" %s",dict[i]); } else if(strlen(tmp)==strlen(dict[i])+1){ j = 0; while(j<strlen(dict[i])&&tmp[j]==dict[i][j])j++; while(j<strlen(dict[i])&&tmp[j+1]==dict[i][j])j++; if(j==strlen(dict[i])) printf(" %s",dict[i]); } else if(strlen(tmp)==strlen(dict[i])-1){ j = 0; while(j<strlen(tmp)&&tmp[j]==dict[i][j])j++; while(j<strlen(tmp)&&tmp[j]==dict[i][j+1])j++; if(j==strlen(tmp)) printf(" %s",dict[i]); } } printf("\\n"); } return 0; }
POJ题目总结
(1)深度优先搜索 (poj2488,poj3083,poj3009,poj1321,poj2251)
(2)广度优先搜索(poj3278,poj1426,poj3126,poj3087.poj3414)
(3)简单搜索技巧和剪枝(poj2531,poj1416,poj2676,1129)
(1)枚举. (poj1753,poj2965)
(2)贪心(poj1328,poj2109,poj2586)
(6)模拟法.(poj1068,poj2632,poj1573,poj2993,poj2996)
简单模拟
1006, 1008, 1013, 1016, 1017, 1169, 1298, 1326, 1350, 1363, 1676, 1786,
1791, 1835, 1970, 2317, 2325, 2390,
以上是关于poj 1035(水题,注意增删时的操作)的主要内容,如果未能解决你的问题,请参考以下文章