读书人

gcc编译器,该如何解决

发布时间: 2012-04-28 11:49:53 作者: rapoo

gcc编译器
[june@localhost cfile]$ cat q.c
#include <stdio.h>
#include <math.h>

int main()
{
int x = 24;
double y = 17;

printf("%d\n",8/* sqrt(x)*/);
printf("%d\n", sqrt(y));


}
[june@localhost cfile]$ gcc q.c -lm
[june@localhost cfile]$ ./a.out
8
1722805511
[june@localhost cfile]$


[解决办法]
sqrt返回值为浮点,用%f输出应该就没问题了

读书人网 >C++

热点推荐