回复 10楼 nosnoy
同意你的观点。在C++的时候,A也A++。B也B++,同时它们是一环套一环的,不会遗漏解的。
2018-05-13 19:57
~[此贴子已经被作者于2018-5-13 20:27编辑过]

2018-05-13 20:16
2018-05-13 20:32
2018-05-13 20:32
2018-05-13 20:44
程序代码:#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);
}
}
}
}
}
2018-05-14 09:28
程序代码:
#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编辑过]

2018-05-14 09:45
2018-05-14 14:15