Визначимо функції мінімуму та максимуму двох чисел. З їх допомогою обчислимо потрібний вираз.
Визначимо функції мінімуму min та максимуму max двох чисел.
double min(double x, double y)
{
return (x < y) ? x : y;
}
double max(double x, double y)
{
return (x > y) ? x : y;
}Основна частина програми. Читаємо вхідні дані. Обчислюємо та виводимо відповідь.
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)