#include <iostream>
using namespace std;
int main() {
int n, k=0;
cin>>n;
int arr[n];
for (int i=0; i<n; ++i) {cin>>arr[i]; if (arr[i]%2==0&&(arr[i]<arr[k]||arr[k]%2==1)) k=i;}
cout<<arr[k];
return 0;
}
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main() {
int n, k=0;
cin>>n;
int arr[n];
for (int i=0; i<n; ++i) {cin>>arr[i]; if (arr[i]%2==0&&(arr[i]<arr[k]||arr[k]%2==1)) k=i;}
cout<<arr[k];
return 0;
}