dalao 20pts 求调!!!
查看原帖
dalao 20pts 求调!!!
1285008
Genshin_Balladeer楼主2024/8/26 09:31
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string w,a;
    cin>>w;
    getline(cin,a);
    int c=0;
    int f=-1;
    int pos=0;
    while((pos=a.find(w,pos))!=string::npos){
        if(f==-1){
            f=pos;
        }
        c++;
        pos++;
    }
    if (c==0){
        cout<<-1<<endl;
    }else{
        cout<<c<<" "<<f<<endl;
    }
    return 0;
}
2024/8/26 09:31
加载中...