Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- double oddSum = 0, oddMin = 1000000000.0, oddMax = -1000000000.0,
- evenSum = 0, evenMin = 1000000000.0, evenMax = -1000000000.0, number;
- for (int i = 1; i <= n; i++) {
- cin >> number;
- if (i % 2 == 1) {
- oddSum += number;
- if (number < oddMin) {
- oddMin = number;
- }
- if (number > oddMax) {
- oddMax = number;
- }
- }
- else {
- evenSum += number;
- if (number < evenMin) {
- evenMin = number;
- }
- if (number > evenMax) {
- evenMax = number;
- }
- }
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- if (n == 0) {
- cout << "OddSum=0.00, \nOddMin=No, \nOddMax=No,\n";
- }
- else {
- cout << "OddSum=" << oddSum << ",\nOddMin=" << oddMin << ",\nOddMax=" << oddMax << ",\n";
- }
- if (n <= 1) {
- cout << "EvenSum=0.00, \nEvenMin=No, \nEvenMax=No\n";
- }
- else {
- cout << "EvenSum=" << evenSum << ",\nEvenMin=" << evenMin << ",\nEvenMax=" << evenMax << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement