POJ 3096 Surprising Strings

mac2022-06-30  121

这个题是对STL中Map的使用考察。

记录一下代码:

#include <stdio.h> #include <map> #include <string.h> #include <string> using namespace std; int main() { char s[100]; while(scanf("%s",s),s[0]!='*') { int p=strlen(s),i,j; if(p<3) { printf("%s is surprising.\n",s); continue; } bool flat=1; for(i=1;i<p;i++) { map<string ,bool> map1; for(j=0;j<p-i;j++) { char c[3]={s[j],s[j+i],'\0'}; if(!map1[c]) { map1[c]=1; } else { flat=0; break; } } if(!flat) { break; } } if(flat) { printf("%s is surprising.\n",s); } else { printf("%s is NOT surprising.\n",s); } } return 0; }

转载于:https://www.cnblogs.com/lin375691011/p/3996740.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)