Run ID:136463
提交时间:2025-11-15 10:26:32
#include <iostream> #include <cstring> using namespace std; int main() { while(1) { string s; int count1 = 0; int count2 = 0; cin >> s; if(s == "#")break; char finlly = s.back(); string s2 = s.substr(0,s.size()-1); for(int i = 0; i < s2.size();i++) { if(s2[i] == '1') { count1++; } } char replace_char; if(finlly == 'e') { replace_char = count1 % 2 == 0 ? '0':'1'; }else { replace_char = count1 % 2 == 0 ? '1':'0'; } cout <<s2<<replace_char << endl; } }