大佬们帮我看看吧,STL八十多分
查看原帖
大佬们帮我看看吧,STL八十多分
1005994
TiAm0楼主2023/7/15 09:34
#include <iostream>
#include<string>
using namespace std;
int main()
{
	int n, a, b, c,w=0,s=0;
	string dt;
	cin >> n>>dt;
	b = dt.find("VV");
	c = dt.find("KK");
	if ((b >= 0 && b <= dt.size()) || (c >= 0 && c <= dt.size()))
		w = 1;
	while (dt.find("VK")>=0&& dt.find("VK")<=dt.size()){
		a = dt.find("VK");
		if (a + 2 >= 0 && a + 2 <= dt.size()) {
			dt = dt.substr(a + 2, dt.size());
			s++;
		}
	}
	cout << s + w;
}
2023/7/15 09:34
加载中...