解题思路:
注意事项:
参考代码:
#include
int main()
{
int a,b,i,temp;
scanf("%d %d",&a,&b);
if(a<b){
temp=a;
}
else
temp=b; //判断循环
for(i=2;i<temp;i++){
if(a%i==0&&b%i==0)
c=i;
}
printf("%d ",c); //最大公约数
printf("%d\n",c*(a/c)*(b/c)); //最小公倍数
//printf("%d",(a*b)/c); //假设x和y的最大公约数是m,最小公倍数是n,则xy=mn
return 0;
}
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:669 |
C语言训练-排序问题<1> (C语言代码)浏览:632 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:882 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:530 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:496 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:503 |
马拦过河卒 (C语言代码)浏览:1198 |
C语言程序设计教程(第三版)课后习题11.1 (C++代码)浏览:706 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:2748 |
1227题解浏览:574 |