Define the minimum and maximum functions of two numbers. With their help, we will calculate the required expression.
Define the minimum min and maximum max functions of two numbers.
double min(double x, double y)
{
return (x < y) ? x : y;
}
double max(double x, double y)
{
return (x > y) ? x : y;
}The main part of the program. We read the input data. Calculate and output the answer.
scanf("%lf %lf %lf",&x,&y,&z);
res = min(min(max(x,y),max(y,z)),x+y+z);
printf("%.2lf\n",res);import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
con.useLocale(Locale.US);
double x = con.nextDouble();
double y = con.nextDouble();
double z = con.nextDouble();
double res = Math.min(Math.min(Math.max(x, y), Math.max(y, z)), x + y + z);
System.out.println(res);
con.close();
}
}import java.util.*;
public class Main
{
public static double min(double x, double y)
{
return (x < y) ? x : y;
}
public static double max(double x, double y)
{
return (x > y) ? x : y;
}
public static void main(String[] args)
{
Scanner con = new Scanner(System.in);
double x = con.nextDouble();
double y = con.nextDouble();
double z = con.nextDouble();
double res = min(min(max(x, y), max(y, z)), x + y + z);
System.out.println(res);
con.close();
}
}x, y, z = map(float, input().split())
res = min(min(max(x, y), max(y, z)), x + y + z)
print(res)