回复 10楼 nosnoy
同意你的观点。在C++的时候,A也A++。B也B++,同时它们是一环套一环的,不会遗漏解的。
假设~
c是勾股数,对应的是a1,b1
c+1也是勾股数,对应的是a2,b2
这样有没没有a1>a2的可能呢~
此时
a1>b1
a2>b2
也是满足的~
就是不知道有没有这种可能
~[此贴子已经被作者于2018-5-13 20:27编辑过]
程序代码:#include<stdio.h>
int main()
{
int count=0,a,b,c,d;
scanf("%d",&c);
for(c>0;c;c++)
{
for(a=1;a<c;a++)
{
for(b=1;b<a;b++)
{
if(c*c==a*a+b*b)
{
count++;
printf("NO%d=%d ",count,c);
printf("NO%d=%d ",count,a);
printf("NO%d=%d\n",count,b);
c++ ;
if(count==4)
return 0;
printf("c = %d ",c);
}
}
}
}
}
程序代码:
#include<stdio.h>
void fun1( int );
void fun2( int );
int main( void )
{
const int k=1096;
fun1(k);
puts("");
fun2(k);
return 0;
}
void fun1( int c )
{
int count=0,a,b;
for(c>0;c;c++)
{
for(a=1;a<c;a++)
{
for(b=1;b<a;b++)
{
if(c*c==a*a+b*b)
{
count++;
printf("c->NO%d=%-6d ",count,c);
printf("a->NO%d=%-6d ",count,a);
printf("b->NO%d=%-6d\n",count,b);
c++;
if(count==5)
return ;
}
}
}
}
}
void fun2( int c )
{
int count=0,a,b;
for(c>0;c;c++)
{
for(a=1;a<c;a++)
{
for(b=1;b<a;b++)
{
if(c*c==a*a+b*b)
{
count++;
printf("c->NO%d=%-6d ",count,c);
printf("a->NO%d=%-6d ",count,a);
printf("b->NO%d=%-6d\n",count,b);
//c++;
if(count==5)
return ;
a=c;
b=a;
}
}
}
}
}
~[此贴子已经被作者于2018-5-14 13:07编辑过]
