为何定义的是int,用%d却打印不出来,要用%g或者%f?
#include <stdio.h>int main()
{
int i,c;
scanf("%d",&i);
c=i/200000;
switch(c)
{
case 0:printf("%d",i*0.1);break;
case 1:printf("%d",10000+(i-100000)*0.075);break;
case 2:printf("%d",17500+(i-200000)*0.05);break;
case 3:printf("%d",27500+(i-400000)*0.03);break;
case 4:
case 5:printf("%d",33500+(i-600000)*0.015);break;
default:printf("%d",39500+(i+1000000)*0.01);
}
return 0;
}
谢谢! 因为你打印出的数(计算结果)不一定是整型了,所以要用%f 哦哦,懂了懂了,谢谢
页:
[1]