救救我

P1042 [NOIP2003 普及组] 乒乓球

哥,下次代码写清楚&&不要挤在int main()里
by luozezhong @ 2024-04-06 19:38:54


```c #include <iostream> #include <cmath> using namespace std; char a[62510]; int main() { int h = 0, y = 0; int i = 0; while(true) { i++; cin >> a[i]; if(a[i] == 'W') { h++; } if(a[i] == 'L') { y++; } if(h >= 11 || y >= 11) { if(abs(h - y) >= 2) { cout << h << ":" << y << endl; h = 0; y = 0; } } if(a[i] == 'E') { break; } } cout << h << ":" << y << endl << endl; i = 0; h = 0; y = 0; while(true) { i++; if(a[i] == 'W') { h++; } if(a[i] == 'L') { y++; } if(h >= 21 || y >= 21) { if(abs(h - y) >= 2) { cout << h << ":" << y << endl; h = 0; y = 0; } } if(a[i] == 'E') { break; } } cout << h << ":" << y << endl; return 0; } ``` ###### 但愿能够帮到你
by Alice_zhang @ 2024-04-06 19:46:35


这是满分代码
by Alice_zhang @ 2024-04-06 19:48:07


过了 **谢谢大佬!**
by W_HELLO @ 2024-04-06 20:08:09


此帖已结
by W_HELLO @ 2024-04-06 20:10:10


|