SWUST OJ1157n个数的最小公倍数
作者:互联网
题目描述
求n个数的最小公倍数。
输入
多组测试数据,第一行一个数n (0 < n <= 10),下面n个数,integer范围内。输出
这n个数的最小公倍数。样例输入
5 6 3 5 4 2样例输出
60#include<stdio.h> int main() { int n; int i; int a[100]; int sum; int b[100]; while (scanf("%d", &n) != EOF) { for (i = 0; i < n; i++) { scanf("%d", &a[i]); b[i] = a[i]; } i = 0; while (1) { sum = a[i] % a[i + 1]; a[i] = a[i + 1]; a[i + 1] = sum; if (a[i + 1] == 0) { a[i+1] = b[i] * b[i + 1] / a[i]; b[i+1] = a[i + 1]; if (i == n - 2) { break; } i++; } } printf("%d\n", a[i+1]); } return 0; }
标签:公倍数,样例,sum,个数,int,OJ1157n,SWUST,100 来源: https://blog.csdn.net/weixin_63587703/article/details/122059959