1 like 0 dislike

給定兩個數字,請使用歐幾里得演算法得出它們的最大公因數

 

輸入例子:

12 28

輸出例子:

4

 

[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD by (5.2k points)
Available when: Unlimited - Due to: Unlimited
| 105 views

5 Answers

0 like 0 dislike
Hidden content!
* * * * * * * * **

int main()
{
* *   int a,b,t;
** ** *  
  * ** ** ** *** * *** ****
* * * *
    ** *** *** ** **** ** **
* *   {
* **** t=a-b;
** **   a=b-t;
* ***   b=t-a;
**   }
* *  
    * ***** * ** ** * *** ******* ** * *** * * *
*** * **** ** * * * * ** *
* *   else * ** * ** * ** *** ****** * * *** ** * * ***
** ** * * * *** * **** *** *
* * * * else ** *********** ** ** ** * ** ** ** **
* * * * * * * * **** ** **** **
* * * * * else * ** ** * *** **** **** *** **** * * * * *** **
*** * ** *** * * * ** ***
* * ** ** * else ** * * ***** ** ****** ** * * * * * * **
***** * * * * ***** ** * *
** * * * else *** ** *** *** * ** * * ****
* ** ****** ** * **** * ** ** ***
***** ** *
* **** **** return 0;
}
answered by (215 points)
edited by
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 like 0 dislike
Hidden content!
* **
answered by (215 points)
0 0
prog.c:1:1: error: expected identifier or '(' before '.' token
 .
 ^
0 0
/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
0 like 0 dislike
Hidden content!
** **** * ** *
* ** *** * * * *

int x,int y)
{
*** ** int temp;
**** * *** **** **** ** ***
*** ** * ** ** **** {
*** * ** ** * ** * ***** ** * * ***
** * ** * *** * * **** *** y=x%y;
* * * ***** **** *** * ******* x=temp;
**** ** *** ** *** * * }
* * * ** * * * ** return x;
}

int * *** argc, char const ** *
{
** *** ** * int x,y;

* * *** * * ** * ** ** ** *** * ** ** * * *** *
* * ** * {
* ** ** **** * **** * * ** ** * * * * **** * * );
* * * * * ** * }
* * ** * **
** * * ** * return 0;
}
answered by (114 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
* * * ** *
int main()
{
** ** *   int a, b;
** ** * * * * * ******* **** *****
* ** ** * while( a > 0 ** * ** * b > 0 )
*   {
* ** *** * ***** **** ** a > b )
*** * * * * * * * * ** *** * ** ** ** ***** = a % b;
* * ** *** * **** ******
**** * * ** * ** * ** * ** * ** * ******* * ** * = b % a;
* *   }
*** ** * * ****** ** ** * a == 0 )
** *** ** ***** * ** * * * * * *** * ** * ** ** ***
** * * **** ** **** ***
** ** * * * *** *** * *** ** ** *** * ** * ***** *
* *****   return 0;
}
answered by (202 points)
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
0 like 0 dislike
Hidden content!
* * *** ** * *
int main()
{
* ******   int a, b;
* ** **** * * *** * *** * ** ** *** ***
** * **** * * ** while( a > 0 ***** * *** b > 0 )
* *   {
** * * * * *** *** * * a > b )
*** * * * * * * * ** *** * * **** *** *** = a % b;
* * * ** * * ** * *
* ** **** ** * * * ** * ** *** * * ** * = b % a;
** *****   }
* ** * * * **** * * * a == 0 )
** * **** * ** ** ** * ** * ***** **** ***** * ** *
* * ***** * ** * ** * *
*** ** * **** ** **** * * * ** * * **** ** * ** **** *
* *   return 0;
}
answered by (202 points)
0 0
Case 0: Wrong output
Case 1: Wrong output
Case 2: Wrong output
Case 3: Wrong output
Case 4: Wrong output
0 0
Case 0: Correct output
Case 1: Correct output
Case 2: Correct output
Case 3: Correct output
Case 4: Correct output
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.79.175
©2016-2020

Related questions

1 like 0 dislike
1 answer
[Exercise] Essay (Open question) - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
Available when: Unlimited - Due to: Unlimited
| 53 views
1 like 0 dislike
9 answers
[Exercise] Multichoice - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
Available when: Unlimited - Due to: 2017-10-26 14:30
| 42 views
1 like 0 dislike
3 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in 2017-1 程式設計(一)AD
Available when: Unlimited - Due to: Unlimited
| 124 views
1 like 0 dislike
10 answers
[Exercise] Multichoice - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
Available when: Unlimited - Due to: 2017-10-26 14:30
| 57 views
10,777 questions
120,946 answers
112,852 comments
3,802 users