Răspuns :
#include <iostream>
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int k=0, n, max=0, min=0;
string line, numere;
ifstream fileIn("atestat.in");
if (fileIn.is_open())
{
while ( getline (fileIn, line) )
{
if(k!=1){
n=stoi(line);
k++;
} else {
numere=line;
}
}
}
int sirNr[n];
istringstream ss(numere);
int i=0;
do {
string number;
ss>>number;
if(number!="" && number!=" "){
sirNr[i]=stoi(number);
i++;
}
} while (ss);
fileIn.close();
min=sirNr[0];
max=sirNr[0];
for(int i=0; i<n; i++){
if(sirNr[i]%2==0){
cout<<sirNr[i]<<" ";
}
if(sirNr[i]<min){
min=sirNr[i];
}
if(sirNr[i]>max){
max=sirNr[i];
}
}
cout<<"\na="<<min;
cout<<"\nb="<<max;
ofstream fout("atestat.out");
int a = max;
int b = min;
while(b != 0){
int r = a % b;
a = b;
b = r;
}
fout<<a;
fout.close();
return 0;
}