社区讨论
麻烦看一下,这里有一个问题
学术版参与者 10已保存回复 21
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 21 条
- 当前快照
- 1 份
- 快照标识符
- @mi6x1pm0
- 此快照首次捕获于
- 2025/11/20 12:13 4 个月前
- 此快照最后确认于
- 2025/11/20 16:16 4 个月前
题目描述
给以长字符串和一个单词,判断长字符串是否包含这一单词?
输入输出格式
输入格式:
有2行:
第一行,一个长字符串(一篇短文);
第二行,一个单词。
输出格式:
输出“yes”或"no"
输入输出样例
输入样例#1:
It’s spring. It’s sunny and cloudy today. There are many big trees in the park.
tree
输出样例#1
yes
输入样例#2:
t’s spring. It’s sunny and cloudy today. There are many big trees in the park.
biger
输出样例#2:
no
然后,附上代码:
CPP#include<bits/stdc++.h>
using namespace std;
string s;//一段短文;
string a;//一个单词;
int main()
{
cin>>s;
cin>>a;
for(int i=0;i<s.size();i++)
{
if(s[i]==a) cout<<"yes";
else continue;
}
return 0;
}
错哪啦?
回复
共 21 条回复,欢迎继续交流。
正在加载回复...