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
| 27 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 (154 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:108.162.221.93
©2016-2019

Related questions

1 like 0 dislike
1 answer
[Exercise] Essay (Open question) - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (20.9k points)
Available when: Unlimited - Due to: Unlimited
| 28 views
1 like 0 dislike
9 answers
[Exercise] Multichoice - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (20.9k points)
Available when: Unlimited - Due to: 2017-10-26 14:30
| 3 views
1 like 0 dislike
10 answers
[Exercise] Multichoice - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (20.9k points)
Available when: Unlimited - Due to: 2017-10-26 14:30
| 3 views
1 like 0 dislike
3 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in 2017-1 程式設計(一)AD
Available when: Unlimited - Due to: Unlimited
| 30 views
8,045 questions
60,931 answers
33,050 comments
1,170 users