输入包括一个字符串,字符串长度不超过100。
可能有多组测试数据,对于每组数据, 对于字符串中的每一个字符,输出按题目进行奇偶校验后的数,每个字符校验的结果占一行。
3 3a
10110011 10110011 01100001
while True: try: string=input() for i in string: res=bin(ord(i)).replace("0b","").rjust(8,"0") print("1"+res[1:] if res.count("1")%2==0 else res) except: break
while True: try: for c in raw_input(): s = '{:07b}'.format(ord(c)) print '1' + s if s.count('1') & 1 == 0 else '0' + s except EOFError: break
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题