| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 158675 | 林睿 | 字符串的奇偶性 | C++ | Accepted | 1 MS | 280 KB | 681 | 2026-08-22 16:31:24 |
#include <iostream> #include <string> using namespace std; int main() { string s; while (cin >> s) { if (s == "#") break; int cnt1 = 0; for (int i = 0; i < s.size() - 1; i++) { if (s[i] == '1') cnt1++; } char op = s.back(); char add; if (op == 'e') { if (cnt1 % 2 == 0) add = '0'; else add = '1'; } else { if (cnt1 % 2 == 1) add = '0'; else add = '1'; } string ans = s.substr(0, s.size()-1) + add; cout << ans << endl; } return 0; }