c练习题1:求最大公约数,最小公倍数

来源:互联网 发布:linux tcpdump 用法 编辑:程序博客网 时间:2024/06/06 04:29
#include "stdio.h"
int main()
{
int a,b,x,y,temp=1;
printf("请输入两个整数:");
scanf("%d%d",&a,&b);
x=a;
y=b;

while (temp!=0)
{
temp=x%y;
x=y;
y=temp;
}
temp=a*b/x;
printf("公约数为%d\n",x);
printf("最小公倍数为%d\n",temp);


return 0;
}
0 0
原创粉丝点击