#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<windows.h>
int main()
{
int a = 0, b = 0,i=0;
printf("请输入a的值 a=");
scanf("%d", &a);
printf("请输入b的值 b=");
scanf("%d", &b);
{
if (a > b)
i = b;
else
i = a;
}
{
while (a%i != 0 || b%i != 0)
i--;
}
printf("最大公约数=%d\n", i);
system("pause");
return 0;
}
#include<stdio.h>
#include<windows.h>
int main()
{
int a = 0, b = 0,i=0;
printf("请输入a的值 a=");
scanf("%d", &a);
printf("请输入b的值 b=");
scanf("%d", &b);
{
if (a > b)
i = b;
else
i = a;
}
{
while (a%i != 0 || b%i != 0)
i--;
}
printf("最大公约数=%d\n", i);
system("pause");
return 0;
}