我会直截了当地说。
int a,b,c, Number;
a=0;
b=1;
c=2;
Number = (a*100)+(b*10)+(c*1);
printf("%d", Number);
结果是12.
我还有另一个等于12的变量。
int number2 = 12;
现在我必须检查它们之间的区别。我该怎么做?
答案 0 :(得分:1)
只需使用如下所示的if
语句: -
int diff = 0;
if ( Number > number2 )
{
diff = Number - number2;
printf("Number is greater than number2 by %d\n", diff);
}
else if( number2 > Number )
{
diff = number2 - Number;
printf("number2 is greater than Number by %d\n", diff);
}
else
printf("Numbers are equal \n");