#include "stdio.h"
#include "time.h"
#include "stdlib.h"
int fun(int x, int y)
{
//求两个数的最大公约数
int z;
z = x % y;
while (z != 0)
{
x = y;
y = z;
z = x % y;
}
return y;
}
int main(void)
{
int a[10], i, j, z = 1;
srand(time(NULL));
for (j = 0; j < 5; j++)
{
for (i = 0; i < 10; i++)
{
a[i] = rand() % 90 + 10;
printf("%d ", a[i]);
}
putchar('\n');
for (i = 0; i < 10; i++)
z = fun(z, a[i]);
printf("最大公约数: %d\n\n", z);
z=1;
}
return 0;
}
温馨提示:答案为网友推荐,仅供参考