Codeforces 1760A Medium Number Solution & Explanation

Difficulty : 800

Problem Description

Given three distinct integers a, b, and c, find the medium number between all of them.

The medium number is the number that is neither the minimum nor the maximum of the given three numbers.

For example, the median of 5,2,6 is 5, since the minimum is 2 and the maximum is 6.

Input

he first line contains a single integer t (1≤t≤6840) — the number of test cases.

The description of each test case consists of three distinct integers a, b, c (1≤a,b,c≤20).

Output

For each test case, output a single integer — the medium number of the three numbers.

Examples

Input9
5 2 6
14 3 4
20 2 1
1 2 3
11 19 12
10 8 20
6 20 3
4 1 3
19 8 4
Output5
4
2
2
12
10
6
3
8

Solution

The simplest method is to use the built-in Sort method available in each language, and then retrieve the second element (index=1) which is the median number.

C# Solution

Solution1

int t = int.Parse(Console.ReadLine());

for(int i=0; i<t; i++){
    int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    Array.Sort(arr);
    Console.WriteLine(arr[1]);
}
Klook.com

Conclusion

🧡 It would be my pleasure if my solution proves helpful to you!

🧡 If you find my posts valuable, I would greatly appreciate your support through sharing. Thank you in advance!

✅ If you encounter any issues with the explanation or require solutions in other programming languages, please don’t hesitate to reach out to me!

The problem link : Problem – 1760A – Codeforces

Some Random Codeforces Posts

Leave a Reply

Your email address will not be published. Required fields are marked *