【C语言】这个程序该如何分析填补?

设计一个函数MaxCommonFactor(),利用欧几里德算法(也称辗转相除法)计算两个正整数的最大公约数。

代码如下,按要求在空白处填写适当的表达式或语句,使程序完整并符合题目要求。

#include <stdio.h>

int MaxCommonFactor(int a, int b);

int main()

{

 int a, b, x;

 printf("Input a,b:");

 scanf("%d,%d", &a, &b);

 x =_______________ ;

  

 if (x != -1)

 {

      printf("MaxCommonFactor = %d\n", x);

 }

 else

 {

      printf("Input error!\n");

 }

  

 return 0;

}

//函数功能: 计算两个正整数的最大公约数,-1表示没有最大公约数

int MaxCommonFactor(int a, int b)

{

 int r;

 if (a<=0 || b<=0) return -1; // 保证输入的参数为正整数

      

 do{

      ____________;

      a = b;

      _____________;

 }while (__________);

  

 return  a;   

}

A.
第8行: MaxCommonFactor(a, x)

第29行: r = b % a

第31行: b = r

第32行: r = 0

B.
第8行: MaxCommonFactor(a, b)

第29行: r = a % b

第31行: b = r

第32行: r != 0

C.
第8行: MaxCommonFactor(x, b)

第29行: r = a / b

第31行: a = r

第32行: r != 0

D.
第8行: MaxCommonFactor(a, b, x)

第29行: r = a % b

第31行: a = r

第32行: r == 0

int MaxCommonFactor( int a, int b)
{ 
    int c; 
    if(a<=0||b<=0) 
    return -1; 
    while(b!=0)
    { 
     c=a%b; 
     a=b;
     b=c;
    } 
    return a; 
}   
————————————————
版权声明:本文为CSDN博主「Jason Li808」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/JasonLi808/article/details/116002839