1 like 0 dislike
668 views

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

 

輸入例子:

12 28

輸出例子:

4

 

[Exercise] Coding (C) - asked in 2017-1 程式設計(一)AD by (5.2k points)
ID: 29809 - Available when: Unlimited - Due to: Unlimited
| 668 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
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.130.224
©2016-2024

Related questions

1 like 0 dislike
1 answer
[Exercise] Essay (Open question) - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 28891 - Available when: Unlimited - Due to: Unlimited
| 273 views
1 like 0 dislike
9 answers
[Exercise] Multichoice - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 28888 - Available when: Unlimited - Due to: 2017-10-26 14:30
| 569 views
1 like 0 dislike
3 answers
[Exercise] Coding (C) - asked Nov 2, 2017 in 2017-1 程式設計(一)AD
ID: 29808 - Available when: Unlimited - Due to: Unlimited
| 708 views
1 like 0 dislike
10 answers
[Exercise] Multichoice - asked Oct 26, 2017 in 2017-1 程式設計(一)AD by 楊修俊 (30k points)
ID: 28890 - Available when: Unlimited - Due to: 2017-10-26 14:30
| 606 views
12,783 questions
183,443 answers
172,219 comments
4,824 users