首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

gcc编译器,该如何解决

2012-04-28 
gcc编译器[june@localhost cfile]$ cat q.c#include stdio.h#include math.hint main(){int x 24do

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输出应该就没问题了

热点排行