C程序找错

来源:百度知道 编辑:UC知道 时间:2024/05/09 13:00:18
#include <math.h>
void main()
{
int i,x,y,z;
for (i=1;i<100000;i++)
{ x=sqrt(i+100);
y=sqrt(i+268);
if(x*x==i+100&&y*y==i+268)
printf("\n%d\n",i);
}
}

#include <stdio.h>

#include <math.h>
void main()
{
long int i,x,y;
for (i=1;i<100000;i++)
{
x=(int)sqrt(i+100);

y=(int)sqrt(i+268);

if(x*x==i+100 && y*y==i+268)

printf("\n%ld\n",i);
}
}

必须包括stdio.h这个头文件。另外因为i太大,要使用long int 数据类型

就一个<math.h>怎么够?
至少还得包含一个<include.h>

还少一个#include<stdio.h> 嘿嘿~ ~~~