C++70分求助!!!
查看原帖
C++70分求助!!!
969476
Sunhaotian2011楼主2023/7/6 20:24

见标题

/*

*/
#include<bits/stdc++.h>
using namespace std;
int main() {
	int w=0,l=0;
	char c;
	string s;
	while(1) {
		cin>>c;
		if(c=='E') {
			break;
		}
		s+=c;
		if(c=='W') {
			w++;
		} else {
			l++;
		}
		if(w>=11&&w-l>=2) {
			cout<<w<<":"<<l<<"\n";
			w=0;
			l=0;
		}
		if(l>=11&&l-w>=2) {
			cout<<w<<":"<<l<<"\n";
			w=0;
			l=0;
		}
	}
	cout<<w<<":"<<l<<"\n\n";
	w=0;
	l=0;
	for(int i=0; i<s.size(); i++) {
		if(s[i]=='W') {
			w++;
		} else {
			l++;
		}
		if(w>=21&&w-l>=2) {
			cout<<w<<":"<<l<<"\n";
			w=0;
			l=0;
		}
	}
	cout<<w<<":"<<l<<"\n\n";
	w=0;
	l=0;
	return 0;
}

2023/7/6 20:24
加载中...