Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
137594 hjx2115 字符串的奇偶性 C++ Accepted 1 MS 268 KB 627 2025-11-20 19:45:38

Tests(1/1):


Code:

#include <bits/stdc++.h> using namespace std; long long i,s; int main() { char a[50]; while (true) { cin>>a; s=0; if (a[0]=='#') break; else { i=0; while (i<strlen(a)) { if (a[i]=='1') s++; i++; } if (s==0 and a[i-1]=='e') a[i-1]='0'; else if (s==0 and a[i-1]=='o') a[i-1]='1'; else if (s%2!=0) { if (a[i-1]=='e') a[i-1]='1'; else a[i-1]='0'; } else { if (a[i-1]=='e') a[i-1]='0'; else a[i-1]='1'; } } cout<<a<<endl; } return 0; }