POJ 3096 Surprising Strings(STL的set应用)
来源:互联网 发布:17网络批发市场新潮都 编辑:程序博客网 时间:2024/06/05 07:21
题目地址:POJ 3096
用set来存储每个长度的字符串,如果查询不存在,就插入到set容器中,如果已经存在,说明冲突。如果最终没有一次冲突,说明是个surpring strings。
代码如下:
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include<algorithm>using namespace std;int main(){ char s[81], s1[10]; int i, j, len, flag, flag1; while(scanf("%s",s)!=EOF) { if(s[0]=='*') break; len=strlen(s); flag1=0; for(i=1;i<=len-2;i++) { set<string>q; flag=0; for(j=0;j<len-i;j++) { s1[0]=s[j]; s1[1]=s[j+i]; s1[2]='\0'; if(q.count(s1)) { flag=1; break; } else { q.insert(s1); } } if(flag) { flag1=1; break; } } if(flag1) { printf("%s is NOT surprising.\n",s); } else printf("%s is surprising.\n",s); } return 0;}
0 0
- POJ 3096 Surprising Strings(STL的set应用)
- POJ 3096-Surprising Strings(set)
- poj 3096 Surprising Strings(stl map的使用)
- POJ 3096 Surprising Strings 【STL】
- POJ 3096 Surprising Strings(STL map)
- Surprising Strings(STL)
- poj 3096 Surprising Strings
- poj 3096 Surprising Strings
- poj 3096 Surprising Strings
- poj 3096 Surprising Strings
- POJ 3096 Surprising Strings
- POJ 3096 Surprising Strings
- POJ 3096 Surprising Strings
- poj 3096 Surprising Strings
- poj 3096 Surprising Strings
- poj 3096 Surprising Strings
- POJ 3096:Surprising Strings
- Surprising Strings(POJ -3096
- \r,\n与\r\n有什么区别?
- 【DP】poj 1159_Palindrome_201408041527
- SDL图像显示在MFC控件上
- Jquery控件superfish
- Mybatis下配置调用Oracle自定义函数返回的游标结果集
- POJ 3096 Surprising Strings(STL的set应用)
- FactoryBean与BeanFactory
- 一个能说明问题的js的原型 prototype的实例--简单易懂
- 使用预处理器进行调试
- Android-数据库Sqlite的创建,查询及在ListView显示
- jQuery学习笔记(一)
- 环保板材选哪个品牌
- hdu 1028
- Microsoft Office Excel cannot access the file, There are several possible reasons