文章
55
粉丝
100
获赞
12
访问
31.1k
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int arr[1000] = {0};
for(int i = 0; i<n; i++){
cin>>arr[i];
}
int max = arr[0],min = arr[0];
for(int i = 0; i<n; i++){
if(arr[i]> max){
max = arr[i];
}
if(arr[i]<=min){
min = arr[i];
}
}
int gongyueshu = 0;
if(max == min) gongyueshu = max;
if(max % min == 0){
gongyueshu = min;
}else{
for(int i = 1; i<min ; i++){
if(max % i == 0 && min %i == 0){
gongyueshu = i;
}
}
}
cout<<min<<" "<<max<<" "<<gongyueshu<<endl;
system("pause");
}
登录后发布评论
暂无评论,来抢沙发