社区讨论
dalao 20pts 求调!!!
P1308[NOIP 2011 普及组] 统计单词数参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @m0abqpst
- 此快照首次捕获于
- 2024/08/26 09:33 2 年前
- 此快照最后确认于
- 2024/08/26 11:44 2 年前
CPP
#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;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...