'commit'
This commit is contained in:
48
TangDou/LuoGuBook/第8章模拟与高精度/P1042.cpp
Normal file
48
TangDou/LuoGuBook/第8章模拟与高精度/P1042.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int N = 25 * 2500 + 10; //每行至多 25 个字母,最多有 2500 行。
|
||||
int a[N];//小华的输赢状态表
|
||||
int idx;
|
||||
|
||||
int main() {
|
||||
char op;
|
||||
while (true) {
|
||||
cin >> op;
|
||||
if (op == 'E') break;
|
||||
if (op == 'W')
|
||||
a[idx++] = 1;
|
||||
else if (op == 'L')
|
||||
a[idx++] = 0;
|
||||
}
|
||||
//开始分析11分
|
||||
int w = 0, l = 0;
|
||||
for (int i = 0; i < idx; i++) {
|
||||
if (a[i])w++; else l++;
|
||||
if ((w >= 11 || l >= 11) && abs(w - l) >= 2) {
|
||||
printf("%d:%d\n", w, l);
|
||||
//下一局开始,清零
|
||||
w = l = 0;
|
||||
}
|
||||
}
|
||||
//存在未打完的没分出胜负的
|
||||
printf("%d:%d\n", w, l);
|
||||
|
||||
//两种计分制中间需要有空行
|
||||
puts("");
|
||||
|
||||
//开始分析21分
|
||||
w = 0, l = 0;
|
||||
for (int i = 0; i < idx; i++) {
|
||||
if (a[i])w++; else l++;
|
||||
if ((w >= 21 || l >= 21) && abs(w - l) >= 2) {
|
||||
printf("%d:%d\n", w, l);
|
||||
//下一局开始,清零
|
||||
w = l = 0;
|
||||
}
|
||||
}
|
||||
printf("%d:%d\n", w, l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user