#include<iostream>
#include<vector>
usingnamespace std;
void printSumMaxMin(const vector<int>& numsVec)
{
int sz = numsVec.size();
int min = numsVec[0];
int max = numsVec[0];
for (int i = 1; i < sz; i++)
{
if (min > numsVec[i])
{
min = numsVec[i];
}
elseif (max < numsVec[i])
{
max = numsVec[i];
}
}
cout << max + min << endl;
}
int main()
{
int n, x;
cin >> n;
vector<int> numsVec;
for (size_t i = 0; i < n; i++)
{
cin >> x;
numsVec.push_back(x);
}
printSumMaxMin(numsVec);
}
To test for odd/even, divide the number by two using the modulus operator. If it divides evenly into itself, then it's an even number. If not, then the number's odd. I hope this helps you.