[求助]大一新生,完成老师作业,求大神指点,本帖不是求作业,请勿删
void main(){
int decimal = 0;
int bits[4] = {1,0,1,1};
int weight0 = 1;
int weight1 = weight0 * 2;
int count = 0;
while(count < 3)
{
decimal = decimal + bits[count]*weight;
weight = weight * 2;
count = count + 1;
}
printf("The result is :%d" , decimal);
}
理论上输出值应该是11,但我弄出来是13,不知错在哪里,求助
[ 本帖最后由 a94118 于 2012-9-28 15:55 编辑 ]