不写成函数二十分,写成函数没分了,有人帮忙看看吗?
查看原帖
不写成函数二十分,写成函数没分了,有人帮忙看看吗?
675459
laobacoder楼主2022/1/31 16:56
#include<iostream>
using namespace std;
#include<string>
#include<cmath>
void fz(int n,string M);
int main()
{
	string M;int HH=0,MM=0;
	cin>>M;
	fz(11,M);HH=0;MM=0;cout<<endl;
	fz(21,M);
	system("pause");
	return 0;
}
void fz(int n,string M){
		int HH=0,MM=0;
		for(int i=0;M[i]!='E';i++){
		if(M[i]=='W'){
		HH++;	
		}		
		if(M[i]=='L'){
		MM++;	
		}		
		if((HH>=n || MM>=n) && abs(HH-MM)>=2){
			cout<<HH<<":"<<MM<<endl;
			HH=0;MM=0;
		}
	}
	cout<<HH<<":"<<MM<<endl;
}
2022/1/31 16:56
加载中...