c程序设计第四版谭浩强
输入两个正整数 求其最大公约数和最小公倍数 (谭浩强c语言程序设计第四版答案)
以下是此题的【c源程序】,需要C++源代码的请点击进入
#include <stdio.h>
int main()
{
int p,r,n,m,temp;
printf("请输入两个正整数n,m:");
scanf("%d,%d,",&n,&m);
if (n<m)
{
temp=n;
n=m;
m=temp;
}
p=n*m;
while(m!=0)
{
r=n%m;
n=m;
m=r;
}
printf("它们的最大公约数为:%d\n",n);
printf("它们的最小公约数为:%d\n",p/n);
return 0;
}
本文链接:http://www.wb98.com/c/post/tanhaoqiang_5.3.html
本站文章搜索: