为啥我cpeditor过了这个过不了啊,是环境问题吗

Kino 2025-03-13 20:43:57

#include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; signed main() { int n;cin>>n; cin.ignore(); string s; string sub; sub="shenchuan"; getline(cin,s); int cnt=0; size_t first=s.find(sub); if(s.find(sub)==string::npos) { cout<<0; return 0; } else { size_t tmp=first; while(tmp!=string::npos) { cnt++; tmp=s.find(sub,tmp+1); } cout<<cnt<<endl; } size_t tmp=first; while(tmp!=string::npos) { cout<<tmp<<' '; tmp=s.find(sub,tmp+1); }
return 0; }