Problem: Even / Odd Positions

Write a program that reads n numbers and calculates the sum, the min and max values of the numbers on even and odd positions (counted from 1). If there is no min / max element, print "No".

Sample Input and Output

Input Output Input Output
6
2
3
5
4
2
1
OddSum=9,
OddMin=2,
OddMax=5,
EvenSum=8,
EvenMin=1,
EvenMax=4
2
1.5
-2.5
OddSum=1.5,
OddMin=1.5,
OddMax=1.5,
EvenSum=-2.5,
EvenMin=-2.5,
EvenMax=-2.5
1
1
OddSum=1,
OddMin=1,
OddMax=1,
EvenSum=0,
EvenMin=No,
EvenMax=No
0 OddSum=0,
OddMin=No,
OddMax=No,
EvenSum=0,
EvenMin=No,
EvenMax=No
5
3
-2
8
11
-3
OddSum=8,
OddMin=-3,
OddMax=8,
EvenSum=9,
EvenMin=-2,
EvenMax=11
4
1.5
1.75
1.5
1.75
OddSum=3,
OddMin=1.5,
OddMax=1.5,
EvenSum=3.5,
EvenMin=1.75,
EvenMax=1.75
1
-5
OddSum=-5,
OddMin=-5,
OddMax=-5,
EvenSum=0,
EvenMin=No,
EvenMax=No
3
-1
-2
-3
OddSum=-4,
OddMin=-3,
OddMax=-1,
EvenSum=-2,
EvenMin=-2,
EvenMax=-2

Hints and Guidelines

The task combines some of the previous tasks: finding the min and max value and sum, as well as processing of elements on even and odd positions. Check them out.

In the current task it is better to work with fractions (not integers). The sum, the min and the max value will also be fractions. We must use a neutral starting value upon finding the min / max value, for example 1000000000.0 or -1000000000.0. If the end result is the neutral value, we will print “No”.

Testing in the Judge System

Test your solution here: https://judge.softuni.org/Contests/Practice/Index/510#10.

results matching ""

    No results matching ""