AN SET2 Q2


Submit solution

Points: 15 (partial)
Time limit: 8.0s
Memory limit: 64M

Authors:
Problem type
Allowed languages
C

Problem Statement

Consider an army selection process in which the parameters such as age(A), height(H), weight(W) of ‘n’ candidates(C) are stored in the form of an integer array. Row corresponds to candidate and the three columns(fixed) are age, height and weight respectively.

Each row contains the details of Age(int type), Height(int type) and Weight(int type) of candidates. Get the number of candidates from the user and perform the following tasks.

  1. Print the 2D array in matrix format

  2. Find the tallest and shortest heights

  3. Range

  4. Average age of the candidates who attended the selection process

where Range is calculated as max height - min height

Input Format

Get the number of candidates from the user in a line. Followed by that, get the array values from the user in a single line. The third line contains the option number.

Output Format

If option is 1, print the matrix.

If option is 2, maximum height(tallest) to be displayed in one line followed by minimum height(shortest) in next line.

If option is 3, display the range value in a line by applying the formula given in the problem statement.

If option is 4, display the average age in a line.

Sample Input1

3

18 155 60 24 152 50 19 153 51

1

Sample Output1

18 155 60

24 152 50

19 153 51

Sample Input2

3

18 155 60 24 152 50 19 153 51

2

Sample Output2

155

152

Explanation - for understanding purpose only

The max height and min height is displayed in separate lines.

Sample Input3

3

18 155 60 24 152 50 19 153 51

3

Sample Output3

3

Explanation - for understanding purpose only

The difference of max height and min height is 3.

Sample Input4

3

18 155 60 24 152 50 19 153 51

4

Sample Output4

20

Explanation - for understanding purpose only

The average age of 3 candidates is 20.


Comments

There are no comments at the moment.