Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
12560 | 蒋瀚辉 | 字符串的奇偶性 | C++ | Accepted | 1 MS | 732 KB | 563 | 2021-05-21 14:45:50 |
#include <bits/stdc++.h> using namespace std; string a; int main() { while(1) { a=""; cin >> a; if(a=="#") break; int len=a.size(); int y=0; for(int i=0;i<len-1;i++) if(a[i]=='1') y++; if(a[len-1]=='e') { if(y%2==0) { a[len-1]='0'; cout << a << endl; } else { a[len-1]='1'; cout << a << endl; } } else { if(y%2==0) { a[len-1]='1'; cout << a << endl; } else { a[len-1]='0'; cout << a << endl; } } } return 0; }