|
static string ConvertIntToBinary(int n)
{
string binary = string.Empty;
int i = n;
int m = 0;
while (i > 1)
{
i = n / 2;
m = n % 2;
binary = m.ToString() + binary;
n = i;
}
if (i > 0) binary = "1" + binary;
return binary;
}
可以请老师举个数字的例子具体说明呢?麻烦了,我看了半天没看懂 |
|