“substr”函数

https://www.luogu.com.cn/problem/P8195?contestId=154515

`

include<bits/stdc++.h>

using namespace std;
int main(){
string s;
cin >> s;
int i;
int count=0;
for(i=0;i<s.length()-6;i++){
if(s.substr(i,8)=="chuanzhi"){
count++;
}
}
cout << count;
return 0;
}
`

s.substr(初位置,长度)==“ 长度 ”

posted @ 2024-01-26 17:08  CXfang10  阅读(21)  评论(0)    收藏  举报