Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
137592 hjx2115 字符串的奇偶性 C++ Wrong Answer 2 MS 272 KB 556 2025-11-20 19:30:46

Tests(0/1):


Code:

#include <bits/stdc++.h> using namespace std; int main() { int i,n,s; 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) a[i-1]='0'; 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; }


Run Info:

------Input------
1010101010101010101010101011010o 0101010101010101010101001010101e 111111111111e 11111e 111111111111o 11111o 000000000000e 00000e 000000000000o 00000o 111100001010101011010e 10010011010010101111111111o 111111111111111100o 00000000000000111e 1100110011001010101101010e 101010101010100101010101o 1110101010100010101010e 1010101011010101010o 1010101010101010o 10101010010101010e #
------Answer-----
10101010101010101010101010110101 01010101010101010101010010101011 1111111111110 111111 1111111111111 111110 0000000000000 000000 0000000000001 000001 1111000010101010110101 100100110100101011111111110 1111111111111111001 000000000000001111 11001100110010101011010101 1010101010101001010101011 11101010101000101010101 10101010110101010101 10101010101010101 101010100101010100
------Your output-----
10101010101010101010101010110101 01010101010101010101010010101011 1111111111110 111111 1111111111111 111110 0000000000000 000000 0000000000000 000000 1111000010101010110101 100100110100101011111111110 1111111111111111001 000000000000001111 11001100110010101011010101 1010101010101001010101011 11101010101000101010101 10101010110101010101 10101010101010101 101010100101010100