问题描述:为什么直接输出会是乱的值?求解,不是指定输出类型是%d整型吗?
#include <stdio.h> #include <math.h> int main(){ int n; n = pow(2,2); printf("%d\n",n); printf("%.f",pow(2,2)); return 0; }
换小点数据测试可以发现,由于pow函数返回的是浮点型,所以用%d输出会出错