提交时间:2024-02-29 17:07:11
运行 ID: 42492
#include<bits/stdc++.h> using namespace std; string up_to_lower(string s) { for (int i = 0; s[i] != '\0'; i++){ if(s[i] >= 'A' && s[i] <= 'Z') { s[i] = s[i] + 32; } } return s; } int main() { string s, t = "lanqiao"; cin >> s; t = up_to_lower(t), s = up_to_lower(s); int cnt = 0, j = 0; for (int i = 0; s[i] != '\0'; i++){ if(s[i] != t[j]) { j = 0; }else if(s[i] == t[j]) { j++; if(j == 7) { cnt++; j = 0; } } } cout << cnt; return 0; } //lanqiaoLanqiaolan,lanqiao,LANQIAOqingshao. /* 1.忽略大小写比较 2.双重循环--其中一个循环变量从0开始 */