Codeforces Round #835 (Div. 4) A. Medium Number
Here are two ways to implement what’s given in the problem:
- Take input as an array [ a 1 , a 2 , a 3 ] [a_1,a_2,a_3] [a1,a2,a3], and sort it. Output the middle element.
- Write two if-statements. The first: if ( a > b (a>b (a>b a n d and and a < c ) a<c) a<c) o r or or ( a < b (a<b (a<b a n d and and a > c ) a>c) a>c), output a a a. Else, if ( b > a (b>a (b>a a n d and and b < c ) b<c) b<c) o r or or ( b < a (b<a (b<a a n d and and b > c ) b>c) b>c), output b b b. Else, output c c c.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T=1;cin>>T;
while(T--)
{
int a[3];
cin>>a[0]>>a[1]>>a[2];
sort(a,a+3);
cout<<a[1]<<endl;
}
return 0;
}