Advertisement
FedchenkoIhor

три числа, порядковый минимального в массиве

Jan 13th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. public class Solution
  2. {
  3. public static void main (String[] args) throws Exception
  4. {
  5. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  6. //объявляем масив типа int с тремя значениями
  7. int[] ar = new int[3];
  8. //заполняем массив с помощью reader присваивая индекс i
  9. for (int i = 0; i < 3; i++){
  10.   ar[i] = Integer.parseInt(reader.readLine());
  11. }
  12.  /*проходим по элементам массива,
  13. с каждым элементом делаем второй проход
  14. и считаем к-во равные ему
  15. */
  16. for (int i : ar){
  17.   int count = 0;
  18.   for (int j : ar){
  19.       if (i==j){
  20.         count++;
  21.       }
  22.    }
  23.   if (count = 1) {
  24.     System.out.println(i);
  25.   }
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement