分割整行读入字符串
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
getline(cin , s);
stringstream ss(s);
while(ss >> s)
{
int a = 0;
for(int i=0; s[i]; i++) a = a*10 + s[i] - '0';
cout<<a<<endl;
}
return 0;
}
string s,t;
cin >> s >> t;
for(auto v : {'a','b','c'})
{
if(count(s.begin(),s.end(),v) != count(t.begin(),t.end(),v))
{
puts("NO");
}
}
https://codeforces.com/contest/1759/problem/A
// find()
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int _;
cin >> _;
while(_--) {
string s;
cin >> s;
string res = "";
for(int i=1; i<=50; i++) res += "Yes";
if(res.find(s) != -1) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}
//substr
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int _;
cin >> _;
while(_--) {
string s;
cin >> s;
string res = "";
for(int i=1; i<=50; i++) res += "Yes";
int len = s.size();
bool ok = false;
for(int i=0; i<3; i++) {
if(res.substr(i,len) == s) {
ok = true;
break;
}
}
if(ok) cout<<"YES\n";
else cout<<"NO\n";
}
return 0;
}
https://bbs.csdn.net/topics/602635627?ops_request_misc=&request_id=&biz_id=&utm_medium=distribute.pc_search_result.none-task-community_post-2~all~es_rank~default-15-602635627.142^v2^es_vector,143^v4^control&utm_term=%E5%88%A0%E9%99%A4%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%AC%A1%E6%95%B0&spm=1018.2226.3001.4187