Nickolay35

Задача на нахождение минимума

Jan 7th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package com.javarush.task.task05.task0531;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.InputStreamReader;
  5.  
  6. /*
  7. Совершенствуем функциональность
  8. */
  9.  
  10. public class Solution {
  11.  
  12. public static void main(String[] args) throws Exception {
  13. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  14. int a = Integer.parseInt(reader.readLine());
  15. int b = Integer.parseInt(reader.readLine());
  16. int c = Integer.parseInt(reader.readLine());
  17. int d = Integer.parseInt(reader.readLine());
  18. int e = Integer.parseInt(reader.readLine());
  19.  
  20. int minimum = min(a, b, c, d, e);
  21.  
  22. System.out.println("Minimum = " + minimum);
  23. }
  24.  
  25.  
  26. public static int min(int a, int b, int c, int d, int e) {
  27.  
  28. int minimum = a <= b ? a : b;
  29. minimum = minimum < c ? minimum : c;
  30. minimum = minimum < d ? minimum : d;
  31. minimum = minimum < e ? minimum : e;
  32. return minimum;
  33. }
  34. }
Add Comment
Please, Sign In to add comment