huanfen @ 2024-08-25 20:14:49
char match[62503];
int main() { int i = 0; int ME, enemy; ME = enemy = 0; while ((match[i++] = getchar()) != 'E')//输入值W、L、E {
}
//十一场比赛打印并输出
for (i = 0; match[i] != 'E'; i++)//循环条件当遇到'E'停止循环
{
if (match[i] == 'W')//华华胜
{
ME++;
}
else
if (match[i] == 'L')//对手胜
{
enemy++;
}
if ((ME == 11 || enemy == 11) && abs(enemy - ME) >= 2)//打印条件
{
printf("%d:%d\n", ME, enemy);
ME = enemy = 0;
}
}
printf("%d:%d\n", ME, enemy);//未完成的一局or重置一局
printf("\n");
ME = enemy = 0;
//21场制(复制11场制)
for (i = 0; match[i] != 'E'; i++)
{
if (match[i] == 'W')
{
ME++;
}
else
if (match[i] == 'L')
{
enemy++;
}
if ((ME == 21 || enemy == 21) && abs(ME - enemy) >= 2)
{
printf("%d:%d\n", ME, enemy);
ME = enemy = 0;
}
}
printf("%d:%d\n", ME, enemy);
return 0;
}
by LiZeChen_1 @ 2024-08-25 20:25:02
哥们泥头文件呢???
by _IOI_THANKFUL @ 2024-08-25 20:29:19
不是,你代码块没框选全啊!!!
by _IOI_THANKFUL @ 2024-08-25 20:29:30
@huanfen
by LiZeChen_1 @ 2024-08-25 20:30:10
帮你改了一下,可以通过 通过记录
#include <bits/stdc++.h>
using namespace std;
int main() {
char match[62503];
int i = 0;
while ((match[i++] = getchar()) != 'E') {}
int ME = 0, enemy = 0;
for (i = 0; match[i] != 'E'; i++) {
if (match[i] == 'W') {
ME++;
} else if (match[i] == 'L') {
enemy++;
}
if ((ME >= 11 || enemy >= 11) && abs(ME - enemy) >= 2) {
printf("%d:%d\n", ME, enemy);
ME = enemy = 0;
}
}
printf("%d:%d\n", ME, enemy);
printf("\n");
ME = enemy = 0;
for (i = 0; match[i] != 'E'; i++) {
if (match[i] == 'W') {
ME++;
} else if (match[i] == 'L') {
enemy++;
}
if ((ME >= 21 || enemy >= 21) && abs(ME - enemy) >= 2) {
printf("%d:%d\n", ME, enemy);
ME = enemy = 0;
}
}
printf("%d:%d\n", ME, enemy);
return 0;
}
by huanfen @ 2024-08-25 20:31:57
@LiZeChen_1 woc!!!
by huanfen @ 2024-08-25 20:33:28
@_IOI_THANKFUL 哦哦哦哦哦--think 油