文章
47
粉丝
109
获赞
8
访问
28.3k
#include<stdio.h>
int gcd(int a, int b) {
if (b == 0) return a;
else return gcd(b, a % b);
}
int main() {
int n;
scanf("%d", &n);
int s[105];
for (int i = 0; i < n; i++) {
scanf("%d", &s[i]);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (s[j] > s[j + 1]) {
int t = s[j];
s[j] = s[j + 1];
s[j + 1] = t;
}
}
}
//for (int i = 0; i < n; i++) {
// printf("%d",s[i]);
//}
int max = s[n - 1];
int min = s[0];
int g = gcd(max, min);
printf("%d %d %d",min,max,g);
return 0;
}
登录后发布评论
暂无评论,来抢沙发