C++ string查找示例
来源:互联网 发布:帝国cms模板目录 编辑:程序博客网 时间:2024/04/30 06:42
查找两个字符串中的公共字符;
返回公共字符的索引;
#include<iostream>#include<string>using namespace std;int main(){string s = "**Gteate Wall**!";string t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";cout<<"s: "<<s<<endl;cout<<"t: "<<t<<endl;int first=s.find_first_of(t);if(first == string::npos){cout<<"s中所有字符均不在t中"<<endl;}else {cout<<"s中出现在t中的字符的第一个字符:"<<s[first]<<endl;}int last = s.find_last_of(t);if(last == string::npos){cout<<"s中所有字符均不在t中"<<endl;return 1;}else {cout<<"s中出现在t的字符的最后一个字符:"<<s[last]<<endl;return 1;}}
0 0
- C++ string查找示例
- C++string的一个示例
- [复习]c++string用法示例
- [C++]string类的查找函数
- C++string:查找、替换、插入、删除等
- C++-string截取、替换、查找字子串函数
- C++【String类】String查找单个字符,查找字符串的函数实现
- linux c/c++ 段错误(Segmentation fault 查找示例2)
- string查找
- string----------查找
- codeforces 676C Vasya and String 前缀数组+二分查找
- Codeforces 676 C Vasya and String【二分查找+预处理】
- C++string中用于查找的find系列函数浅析
- 浅析C++string中用于查找的find函数
- C++string中用于查找的find系列函数浅析
- C/C++ string库(string.h)提供了几个字符串查找函数
- C/C++ string库(string.h)提供了几个字符串查找函数
- 折半查找算法示例
- apache 允许局域网访问设置
- 设计模式六大原则(4):接口隔离原则ISP(Interface Segregation Principle)
- MySQL 5.6 忘记root密码怎么办!!!淡定
- 深入理解数组,内存中的数组
- vs2012的项目怎么在vs2010中打开
- C++ string查找示例
- Tiny6410 简单的LED字符设备驱动
- Effective C++读书笔记
- PostgreSQL忘记密码的解决办法
- C++编程
- VM9下安装mac lion10.7 黑苹果
- STM32中断入口地址与中断服务函数的关系
- 项目总结——可维护的css/style
- wamp 修改配置文件控制访问权限