In the three variables a, b, and c, three integer pairs of unequal numbers are explicitly written by the programmer. Create a program that rearranges the numbers in variables so that when displaying a sequence of a, b and c was strictly increasing.
Input example: a = 14; b = 10; c = 23; Result: a = 10; b = 14; c = 23;
I did like this
public static void main(String args []){ int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int x; System.out.println("Числа в переменных a, b и c : " + a + " " + b + " " + c); if (a > b) { x = a; a = b; b = x; } if (b > c){ x = b; b = c; c = x; } System.out.println("Возрастающая последовательность: " + a + " " + b + " " + c); }
Минимальное - мин(а, мин(б, в)). Среднее - (а + б + в - макс(а, макс(б, в)) - мин(а, мин(б, в)). Самое большое - макс(а, макс(б, в))Минимальное - мин(а, мин(б, в)). Среднее - (а + б + в - макс(а, макс(б, в)) - мин(а, мин(б, в)). Самое большое - макс(а, макс(б, в))? - entithat