C语言的题,帮帮我啊!!!

来源:百度知道 编辑:UC知道 时间:2024/09/22 09:45:53
程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0<repeat<10),做 repeat 次下列运算:
输入两个正整数m和n,输出它们的最小公倍数和最大公约数。
输入输出示例:括号内为说明
输入:
3 (repeat=3)
3 7 (m=3,n=7)
24 4 (m=24,n=4)
24 18 (m=24,n=18)
输出:
21 is the least common multiple of 3 and 7, 1 is the greatest common divisor of 3 and 7.
24 is the least common multiple of 24 and 4, 4 is the greatest common divisor of 24 and 4.
72 is the least common multiple of 24 and 18, 6 is the greatest common divisor of 24 and 18.

#include <stdio.h>
int main(void)
{
int gcd, lcm, m, n;
int repeat, ri;

scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%d", &m);
scanf("%d", &n);
if(m <= 0 || n <= 0)
printf("m <= 0 or n <= 0");
else{
/*---------*/
printf("%d

#include <stdio.h>
main()
{
int repeat;
int a,b,c,t,i;
printf("Input repeat:");
scanf("%d",&repeat);
for(i=0;i<repeat;i++)
{
printf("Input two numbers:");
scanf("%d%d",&a,&b);
t=a*b;
while(b)
{
c=a%b;
a=b;
b=c;
}
printf("gongyue:%d.",a);
printf("gongbei:%d.\n",t/a);
}
}