请帮助我希望 c# 提出这个问题
请输入一个 7 位二进制数:
0010011
您带有奇偶校验位的号码是:
00100111
这是我想出的代码,它可能是错误的,请你纠正它,这样好吗?
{
Console.WriteLine("Please enter a 7- bit binary number");
string number = Console.ReadLine();
int count1 = 0;
int count2 = 0;
for(int i = 0; i < number.Length; i++)
{
count1++;
}
else
{
count2++;
}
if (count1 < count2)
Console.WriteLine("Your number with parity bit is "+ number+ "1");
}
else
{
Console.WriteLine("Your number with parity bit is "+ number + "0");
}
}
}
}
提前谢谢帮助