有关字符串查找的问题
2012-06-19 16:47
176 查看
//比如说现在有一个程序,要求用户一个字符串一个字符串的输入,如果当前所输入的字符串和之前所输入的字符串有所重复,则打印字符串重复的信息!如果输入结束时没有//重复则在最后打印无字符串重复的信息! //下面的例子如下:假设按照如下的字符串输入顺序输入字符串 now how big small world big……当输入到最后一个字符串也就是big的时候打印信息:字符串有所重复,否///则一直到程序结束打印无字符串重复! //下面是源码: #include <iostream> #include <string> #include <vector> using namespace std; int main() { vector<string> strvec; vector<string>::iterator str_iter=strvec.begin(); string str; cout<<"please input the strings:"<<endl; while((cin>>str)&&str!="end") { strvec.push_back(str); str_iter=strvec.begin(); while(strvec.size()!=1&&str_iter!=strvec.end()-1&&*str_iter++!=str) ;//空语句 if(str_iter==strvec.end()-1) continue; else cout<<"string repeated!"<<endl; } if(str=="end") cout<<"no repeated!"<<endl; return 0; }
相关文章推荐
- 在字符串中查找字符串问题
- 有关字符串的全排列,组合 等问题
- 字符串查找问题,求解字符串的周期(KMP算法)
- 查找字符串中的最长回文问题评述
- 有关string.Fromat()要格式化的字符串有“{”和“}”的问题
- 有关《查找两个List中的不同元素》的问题解答与编程实践
- 几个经典的和字符串有关的问题
- 急急急!!!有关asp字符串处理的问题,请大虾指点???
- group by 字符串合并 有关问题
- 有关JS截取字符串问题总结
- 程序员编程艺术:第二章、字符串是否包含及匹配/查找/转换/拷贝问题
- 程序员编程艺术:第二章、字符串是否包含及匹配/查找/转换/拷贝问题
- 字符串查找最大值问题
- 查找字符串问题
- 有关字符串作为URL的 UTF8编码和解码的问题。
- C#.NET常见问题(FAQ)-VS如何整个项目中查找字符串
- js中的一个超郁闷问题(有关字符串的length比较问题)
- 程序员编程艺术:第二章、字符串是否包含及匹配/查找/转换/拷贝问题
- 翻译《有关编程、重构及其他的终极问题?》——27.狡猾的BSTR字符串
- MFC 中 有关去除字符串中包含的所有回车符和换行符的有关问题