StringProblem(for lab)
来源:互联网 发布:提醒软件reminder 编辑:程序博客网 时间:2024/06/02 07:30
StringProblem(for lab)
标签(空格分隔): 程序设计实验 c++
本人学院
- StringProblemfor lab
- 标签空格分隔 程序设计实验 c
- 本人学院
- 读题
- my answer
- the standard answer
Give you two strings a, b, determine whether string a contains the string b.
Input Format
The first line contains a integer n, represents the number of tests
The next n lines contain the n prolems.Each line contains two strings a , b.
Output Format
For each problem,if A contains B, output”YES” , otherwise output “NO”(without quotes)
Sample Input
2
abcab abc
aabbc ac
Sample Output
YES
NO
Hint:
请使用c++来完成这个题目
读入输出使用cin cout (使用 iostream库)
字符串使用string类型。(使用string库)
判断包含关系使用string的find函数,以及string::npos
读题
string中的字符串查找
my answer
#include<iostream>#include<string>using namespace std;int main() { int t; cin >> t; while (t--) { string a, b; cin >> a >> b; size_t find = a.find(b, 0); if (find != string::npos) cout << "YES" << endl; else cout << "NO" << endl; } return 0;}
the standard answer
#include <iostream>#include <string>using namespace std;int main() { string a, b; int t; cin >> t; while (t--) { cin >> a >> b; if (a.find(b) != string::npos) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0;}
0 0
- StringProblem(for lab)
- SimpleCalculator(for lab)
- Complex number(for lab)
- poj3224 Go for Lab Cup!
- Account's Balance(for lab)
- ‘孤单北半球’ for DP Lab
- Hands on microsoft lab manual (for 2008)
- POJ 3224 Go for Lab Cup!
- poj 3224 Go for Lab Cup!
- poj 3224 Go for Lab Cup!
- 20140409 Complex again(for lab)
- Valve: The Lab Renderer for Unity
- (15 C++ Lab) Class for Time
- Set(DS)(15C++ for lab)
- POJ 3224 Go for Lab Cup! G++
- Lab
- LAB
- Lab Notes : Altera UniPHY for DDR and QDR
- ToggleButton(开关按钮)
- sql server中,N''表示什么意思?
- 智能指针与memmove同时使用,造成程序崩溃
- RxJava处理网络连接失败和timer()、interval()、delay()之间的区别
- linux hadoop本地集群时间同步
- StringProblem(for lab)
- Android学习之 adb被占用解决办法
- Kafka性能测试方法及Benchmark报告
- ScratchView:一步步打造万能的 Android 刮奖效果控件
- 欢迎使用CSDN-markdown编辑器
- TCP/IP详解,卷1:协议,第六章:ICMP,Internet控制报文协议
- 浅谈最短路径Floyed算法(c)
- 富文本编辑器UEditor <div>自动转换成<p>标签解决方法
- python网络编程——IO多路复用之epoll