注册 登录
编程论坛 C语言论坛

求帮助,新人求吧帮助

shy_wh001 发布于 2019-10-13 11:46, 1491 次点击
#include <stdio.h>
#include <stdlib.h>
int main()
{
    float  a,b,c;
    a=10.1;
    b=10;
    c=a*(b*b);
    printf("%d",c);
   
   
    system("pause");
    return 0;
}

输出结果为什么是536870912
2 回复
#2
rjsp2019-10-13 12:11
float 用 %f
#3
a13056038402019-10-13 22:38
#include <stdio.h>
#include <stdlib.h>
int main()
{
    float  a,b,c;
    a=10.1;
    b=10;
    c=a*(b*b);
    printf("%.0f",c);
    system("pause");
    return 0;
}
你的输出点有问题,float是单精度 %d 运动的是 int 整数型的 零为小数点输出就可以了
1