[求助]编程求100以内的所有勾股数
要整数的勾股数,谢谢时间复杂度尽量小
#include "math.h"
#include "string.h"
void GetPythafromanynaturalNum(int nn)
{
int m =0,n = 0;
int m_max=0,n_max=0;
int x=0,y=0,z=0;
m_max = sqrt(1.0*nn);
n_max = sqrt(1.0*nn/2);
for (n=1;n<n_max;n++)
for(m=n+1;m<m_max;m++)
{
x=m*m-n*n;
y= 2*m*n;
z=m*m+n*n;
printf("The absolute value of x=%d y=%d z=%d \n", x,y,z);
}
}
void main(void)
{
int naturalnum;
naturalnum =100;
GetPythafromanynaturalNum(naturalnum);
}