| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 160620 | 郦辰希 | 字符串的奇偶性 | C++ | Accepted | 1 MS | 292 KB | 903 | 2026-09-24 20:36:47 |
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); string s; while (cin >> s) { if (s == "#") { break; } int len = s.length(); char parityType = s[len - 1]; int countOnes = 0; for (int i = 0; i < len - 1; ++i) { if (s[i] == '1') { countOnes++; } } char checkBit; if (parityType == 'e') { if (countOnes % 2 == 0) { checkBit = '0'; } else { checkBit = '1'; } } else { if (countOnes % 2 == 0) { checkBit = '1'; } else { checkBit = '0'; } } s[len - 1] = checkBit; cout << s << endl; } return 0; }