Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- using namespace std;
- #include <iomanip>
- #include <math.h>
- #include <cmath>
- #include <string>
- int main()
- {
- int n;
- cin >> n;
- double temp;
- double oddsum = 0;
- double evensum = 0;
- double oddmax = INT_MIN;
- double evenmax = INT_MIN;
- double oddmin = INT_MAX;
- double evenmin = INT_MAX;
- for (int i = 1; i <= n; i++)
- {
- cin >> temp;
- if (i % 2 == 0) {
- if (evenmax <= temp)
- {
- evenmax = temp;
- }
- if (evenmin >= temp)
- {
- evenmin = temp;
- }
- evensum += temp;
- }
- if (i % 2 != 0) {
- if (oddmax <= temp)
- {
- oddmax = temp;
- }
- if (oddmin >= temp)
- {
- oddmin = temp;
- }
- oddsum += temp;
- }
- }
- cout << "OddSum=" << fixed << setprecision(2) << double(oddsum) <<"," << endl;
- if (oddmin != INT_MAX) {
- cout << "OddMin=" << fixed << setprecision(2) << double(oddmin) << "," << endl;
- }
- else {
- cout << "OddMin=No," << endl;
- }
- if (oddmax != INT_MIN) {
- cout << "OddMax=" << fixed << setprecision(2) << double(oddmax) << "," << endl;
- }
- else {
- cout << "OddMax=No," << endl;
- }
- cout << "EvenSum=" << fixed << setprecision(2) << double(evensum) << "," << endl;
- if (evenmin != INT_MAX) {
- cout << "EvenMin=" << fixed << setprecision(2) << double(evenmin) << "," << endl;
- }
- else {
- cout << "EvenMin=No," << endl;
- }
- if (evenmax != INT_MIN) {
- cout << "EvenMax=" << fixed << setprecision(2) << double(evenmax) << endl;
- }
- else {
- cout << "EvenMax=No" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement