题目:
程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0
输入输出示例:括号内为说明
输入:
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
int main(void)
{
int gcd, lcm, m, n,t;
int repeat, ri;
int i=0,j=0;
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{
/*---------*/
if(m
m=n;
n=t;}
for(i=m;(i%m!=0)||(i%n!=0);i++){
continue;}
lcm=i;
for(j=n;(m%j!=0)||(n%j!=0);j--){
continue;}
gcd=j;
printf("%d is the least common multiple of %d and %d, %d is the greatest common divisor of %d and %d.\n", lcm, m, n, gcd, m, n);
}
}
汗。C语言哇,太久了,都忘了。这都毕业四年了,又没从事这类工作。
提交到作业上?是什么意思哦