#include <math.h>
void main()
{
int a,b,c=0;
for(a=1;a<=100;a++)
for(b=2;b<=100;b++)
{
c=a*a+b*b;
if(c<=100)
printf(“a=%d b=%d c=%d\n”,a,b,c);
else break;
}
getch();
}
好想不行!!有人帮忙吗?
>> 本文固定链接: http://www.vcgood.com/archives/1933
#include<stdio.h>
void main()
{
int temp1, temp2;
int a,b,c;
for(a=1;a<=100;a++)
for(b=a;b<100;b++)
for(c=b;c<=100;c++)
{
temp1 = a*a + b*b;
temp2 = c*c;
if(temp1 == temp2)
{
printf(“a=%d b=%d c=%d \n “,a,b,c);
}
}
}
好象不行喔!!不全的啊1
如果
3 4 5
4 3 5
算两组的话就不全,
我编写了一个程序,求得total=50,共有50个解
long int total=0L;
//xxxxxxxxxxxxxxxxxxx
void main()
{
int a;
int b;
int c;
int col;
col=0;
for(c=2;c<100;c++)
for(b=1;b<c;b++)
for(a=1;a<=b;a++)
if(c*c==b*b+a*a){
printf(“ [%2d, %2d, %2d] “,a,b,c);
total++;
col++;
if(col>=3){
col=0;
printf(“\n”);
}
}
printf(“\ntotal=%7ld\n”,total);
getch();
}