0 like 0 dislike
494 views
勾股定理(英語:Pythagorean theorem)又稱商高定理、畢達哥拉斯定理、畢氏定理、百牛定理,是平面幾何中一個基本而重要的定理。 勾股定理說明,平面上的直角三角形的兩條直角邊的長度(古稱勾長、股長)的平方和等於斜邊長(古稱弦長)的平方。請設計一個程式,找出週常在N已內所有符合勾股定理的整數三角形三邊長。請注意不要重複喔。

sample input:

100

sample output:

3 4 5
5 12 13
6 8 10
7 24 25
8 15 17
9 12 15
9 40 41
10 24 26
12 16 20
12 35 37
15 20 25
15 36 39
16 30 34
18 24 30
20 21 29
21 28 35
24 32 40
[Exercise] Coding (C) - asked in 2016-1 程式設計(一)AC by (18k points)
ID: 15447 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00

reshown by | 494 views
0 1
#include <stdio.h>
#include <stdlib.h>

int main()

{
    int a,b,c,n;
    scanf("%d",&n);
    for(a=1;a<n;a++)
    {
        for(b=a+1;b<100-a;b++)
        {
            for(c=b+1;c<100-a-b;c++)
            {
            if(a*a+b*b==c*c)
                printf("%d %d %d\n",a,b,c);
            }
        }
    }
    return 0;
}

5 Answers

0 like 0 dislike
Hidden content!
#include<stdio.h>





int main(){

    int x,i,j,k,t=0;
** * * * * * ** ** * * * *** ** *** * *** * *

    for(i=3; i<x ;i++){
* ** ****** * * ** *** * * * ** * * * * * * * j<x-i ;j++){
* * * * *** * * ** **** *** * * * * ** * * * * * ** * * * *** k<x-i-j ;k++){
* * * *** * * ** ** **** * ** ***** ** * * * * ***** *** ** **** ** * * ** * i*i + j*j == k*k ){
*** ***** ****** **** * * ** *** * * * *** **** * *** * ** * * * *** * *** ** * * * * *** * *** * ** * * ** * * *** *
*** ****** ***** ** * ** *** * ** ** * ** * ** * * ** * * ** * ******* *** * * * ** *** * * * ** * * * * ** * ** ****** * ** * *** * * *** * ***


* ** ** ** * ** * ** **** *** * ** * ** ** ** **** * *** ****** ** * * *** * * * * * * * **** * **** * * ** **** ** * %d %d",i,j,k);
* ** ** ** *** **** * * ** **** * * *** ****** ** ** *** * **** * * * **** * * ** * * * * * * * *


* * ** ** * **** *** *** * * * *** ** ** * * ***** * *** * * *** * * ****** * * ** **** *



    }}}



 return 0;

}
answered by (-126 points)
0 like 0 dislike
Hidden content!
#include<stdio.h>





int main(){
** * ******* ***** * * * x,i,j,k;
* ** ** * ***** *** * * *** * * * **
* * * ******** ** * * * * i<x ;i++){
** * * ******** * * *** *** * * ** * ******* * * j<x-i ;j++){
* * *** * * * ******* * *** * ** ** * * ** *** * * ** ** * ***** k<x-i-j ;k++){
* ** ** ** * ******* * * * ** ** **** ***** ***** *** ****** * * ** * * **** i*i + j*j == k*k ){
* ** * *** * * *** ** * ***** ** * * * * * * *** * * ** * * * * * ** * * ** * *** * * * ** * * **** ** * * **** * *** ** * %d %d\n",i,j,k);
* * ** * * * * * ** * ** * ** ** ** **** * ** **** **** *** ** * ** * * * *
****** ** ** * * * * ***



 return 0;

}
answered by (-126 points)
0 like 0 dislike
Hidden content!
** * * ** *** * * *
* * * * * ** *******
** ** * **
* **

** ***** * **** *
*** * * ** * ** * *

** * * *
* * **
*
* * * *
* *
*
* * ***

**** * *** * ** * i * * = i * * * = i * ** * * ** * * **
* *
* * * * ** * * * * * * *** ** * *** ** **
**
** * * * ** * * ** * * = * * *** **** * * *** * ****
* * *
* * * ** * * * * = i * * * ** ** * **** * *
* = *
* = * *** * ** * * * * ** ** * *** *** ***
*
***** *** ** * * * * * * * ***** ** * **
* * *
* * * * ** * * * * *** ** ** **** * ***





*
answered by (-276 points)
0 like 0 dislike
Hidden content!
* ** *** * *
* * * ** *** **
**** **** ** *
** *** ***
*
* * ** *
** * **** *** * ** * * *
*
* * *
* * **
* * *
* * **
* * **
**
*
*
* ** ** * * i * * = i * ** = i * * * ** * * * * * *** * **
**
* * ** *** ** * * * ** * * * ** **** * * ** *****

* * * * * *** * * * = * * ** ** * * * ** * ** *

** * * ** * * * * * * ** = i * * * * ** **** ** ** * *
* = *
* * = * * * * * * ** *** * ** ** * *** * *** * * ***** *
*
* ** ** *** * * * * * * * * * * ** *** * *
* * *
* * *** ** * * * ** * * ** * * * * * * **** *



*
*
* **
**
answered by (-276 points)
0 like 0 dislike
Hidden content!
** * *** ** **** **


** *

{
* ** * **** **** ** a, b, c, n;
** * * ** ****** *** * * * * * *** ** ** * *
**** ** * * ** * * * ***** ** * ** *


** * * * * * ** * * = 1; c *** n; c++)
** * * * * * * *** = 1; a * * * c; a++)
** *** * *** ***** = a +1; b *** c; b++)


* *** ****** ** * (a * a + b * b == c * c)
* ** ** *** * * ** ** %d *** ***** *



}
answered by (-74 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.100.59
©2016-2024

Related questions

0 like 0 dislike
0 answers
[Resource] asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15475 - Available when: Unlimited - Due to: Unlimited
| 13 views
1 like 0 dislike
37 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15446 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 1.6k views
1 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15442 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 946 views
1 like 0 dislike
18 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15440 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 966 views
0 like 0 dislike
112 answers
[Exercise] Coding (C) - asked Oct 27, 2016 in 2016-1 程式設計(一)AC by Shun-Po (18k points)
ID: 15426 - Available when: 2016-10-27 18:30:00 - Due to: 2016-10-27 21:00:00
| 4.5k views
12,783 questions
183,443 answers
172,219 comments
4,824 users