如何 建公司网站,学校建网站,广东网站建设公司电话,湖南旅游B-你好#xff0c;这里是牛客竞赛_牛客周赛 Round 59 (nowcoder.com)
返回值是子串或字符在 string 对象字符串中的位置 #include bits/stdc.h using namespace std; int T; string s; int main() { cin T; while(T --) { cin 这里是牛客竞赛_牛客周赛 Round 59 (nowcoder.com)
返回值是子串或字符在 string 对象字符串中的位置 #include bits/stdc.h using namespace std; int T; string s; int main() { cin T; while(T --) { cin s; if(!s.find(ac.nowcoder.com) || !s.find(https://ac.nowcoder.com)) cout Ac endl; else if(!s.find(www.nowcoder.com) || !s.find(https://www.nowcoder.com)) cout Nowcoder endl; else cout No endl; } } 出问题代码
#includebits/stdc.h
#includecstdio
#define int long long
using namespace std;#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)const int N 2e5 10;signed main(){IOS;int t;cin t;while(t -- ){string s;cin s;string a1 https://;string b1 www.nowcoder;string b2 ac.nowcoder;for(int i 0;i s.length(); i ) {if(s[i] h) {for(int j 1; j 8; j ) {if(s[ij] ! a1[j] ) {cout No endl;break;}}}else if(s[i] b1[0]) {int flag 0;for(int j 1; j a1.length(); j ) {if(s[i j] ! b1[j] ) {flag 1;break;}}if(flag 0) {cout Nowcoder endl;break;}else {cout No endl;break;}}else if(s[i] b2[0]) {int flag 0;for(int j 1; j b2.length(); j ) {if(s[i j] ! b2[j]) {flag 1;break;}}if(flag 0) {cout Ac endl;break;}else {cout No endl;break;}}}}return 0;
}总结
记住string类中可以查找字符串的方法
学习笔记 c 在String查找子串和字符 -CSDN博客