Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Chef is given 3 integers A,B, and C such that CA<B<C.
Chef needs to find the value of max(A,B,C)−min(A,B,C).
Here max(A,B,C) denotes the maximum value among A,B,C while min(A,B,C) denotes the minimum value among A,B,C.
For each test case, output the value of max(A,B,C)−min(A,B,C).
Input:
4
1 3 10
5 6 7
3 8 9
2 5 6
3 10
Output:
9
2
6
4
Test case 1: Here, max(1,3,10)=10 and min(1,3,10)=1. Thus, the difference is 9.
Test case 2: Here, max(5,6,7)=7 and min(5,6,7)=5. Thus, the difference is 2.
Test case 3: Here, max(3,8,9)=9 and min(3,8,9)=3. Thus, the difference is 6.
Test case 4: Here, max(2,5,6)=6 and min(2,5,6)=2. Thus, the difference is 4.
# cook your dish here
for i in range(int(input())):
a,b,c=map(int,input().split())
print(c-a)
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
vector<int>m;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
cout<<max({a,b,c})-min({a,b,c})<<endl;
}
return 0;
}
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int i = s.nextInt();
int ans[]=new int[i];
int min[]=new int[i];
int max[]=new int[i];
for(int j=0;j<i;j++){
for(int k=0;k<3;k++)
{
int a=s.nextInt();
if(a>max[j]){
max[j]=a;
}
if(k==0)
{
min[j]=a;
}
if(a<min[j]){
min[j]=a;
}
}
ans[j]=max[j]-min[j];
}
for(int l=0;l<i;l++){
System.out.println(ans[l]);
}
}
}
In our experience, we suggest you solve this Max minus Min CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Max minus Min CodeChef Solution
I hope this Max minus Min CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>