#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main() {
int a, b, c, d;
printf(“请输入要比较的两个数\n”);
scanf("%d %d", &a, &b);
if (b < a) {//判断a,b的大小。
c = a; a = b; b = c;
}//a,b交换确保a为大值
d = a % b;//取最大值除最小值的余数
while (d != 0) {
a = b; b = d; d = a % b;
}//辗转相除
printf(“最大公约数是%d\n”, b);
system(“pause”);
}
两个整数的最大公约数
猜你喜欢
转载自blog.csdn.net/weixin_44769282/article/details/88662611
今日推荐
周排行