...的平方.编写一程序,输出20以内满足上述条件的整数集合
发布网友
发布时间:2023-12-22 11:09
我来回答
共2个回答
热心网友
时间:2024-07-21 19:40
Dim i As Long, j As Long, k As Long
For i = 1 To 20
For j = i To 20
For k = j To 20
If i ^ 2 + j ^ 2 = k ^ 2 Then Print i; j; k
Next k
Next j
Next i
所有的符合要求的答案是:
3,4,5
5,12,13
6,8,10
8,15,17
9,12,15
12,16,20
热心网友
时间:2024-07-21 19:42
void main()
{
int i,j,k,ii,jj;
for (i=1; i<20;i++)
for (j=i,ii=i*i; j<20; j++)
for (k=j+1,jj=j*j; k<=20; k++)
if (ii+jj==k*k) printf("%d, %d, %d\n",i,j,k);
}