未分类题

请补充main函数,该函数的功能是:输入两个正整数numl和num2,求这两个数的最大公约和最小公倍数。
例如,若输入的两个正整数为12,4,则它们的最大公约数为12,最小公倍数为4。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填人所编写的若干表达式或语句。
试题程序:
include<stdliB.h>
include<stdio.h>
void main
{
int a,b,numl,num2,t;
system("CLS"):
printf("/nInput two numbers:/n");
scanf("%d,%d",&numl,&num2);
if(numl<num2)
{
a=num2;
b=num1:
}
else
{
a=num1;
b=num2;
}
while(【1】)
{
t=【2】
a=b;
b=t:
}
printf(“greatest common divisor:
%d/n",a);
printf("least common multiple:
%d/n",【3】;
}

A.h>
include<stdio.h>

【参考答案】

【1】b!=0【2】a%b[3]numl*num2/a......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)

热门 试题