*最大公因數
user_6817964
c_cpp
3 years ago
364 B
6
Indexable
#include <stdio.h> // printf
int main()
{
int a, b, max, last = 1;
scanf_s("%d%d", &a, &b);
if (a > b)
max = a;
else
max = b;
printf("1");
for (int i = 2; i <= max; i++) {
if (a % i == 0 && b % i == 0) {
printf(" %d", i);
last = i;
}
}
printf("\n%d", last);
}Editor is loading...