30分求调(尽量从我源代码上改,谢谢)
查看原帖
30分求调(尽量从我源代码上改,谢谢)
1369972
shunxinruyi楼主2024/10/20 19:42
#include<bits/stdc++.h>
using namespace std;
char a[3000];
int main()
{
	
	int t=0,l=0;
	do
	{
		cin>>a[t];t++;//输入并记录字符个数 
	}
	while(a[t-1]!='E');
	int b11h=0,b11d=0,b21d=0,b21h=0,c11,c21;
	if(t%11!=0) c11=t/11+1;
	else c11=t/11;//c11:11赛制比赛次数 
	if(t%21!=0) c21=t/21+1;
	else c21=t/21;//21赛制次数 
	int s=0;
	for(int i=1;i<=c11;i++)
	{
		b11h=0;b11d=0;//每次分数归零 
		s+=11;
		if(s>t)
		s=t;//每次结束字符位 
		for(int j=l;j<s;j++)
		{
			if(a[j]=='W') b11h++;//11赛制下每次华赢的比方 
			if(a[j]=='L') b11d++;//对手赢得比分 
		}
		l+=11;
		if(l>t) l=t-(l-11);//下次开始字符位 
		//cout<<l<<" "<<s<<" ";
		cout<<b11h<<":"<<b11d<<"\n";
	}
	s=0,l=0;
	cout<<"\n";
	for(int i=1;i<=c21;i++)//21赛制下的,与上述一样 
	{
		b21h=0;b21d=0;
		s+=21;
		if(s>t)
		s=t;
		for(int j=l;j<s;j++)
		{
			if(a[j]=='W') b21h++;
			if(a[j]=='L') b21d++;
		}
		l+=21;
		if(l>t) l=t-(l-21);
		cout<<b21h<<":"<<b21d<<"\n";
	}
	return 0;
}

2024/10/20 19:42
加载中...