Advertisement
Guest User

Untitled

a guest
Jun 14th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. package ru.koshkina;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Задание3 {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner in = new Scanner(System.in);
  9.         System.out.print("Введите N: ");
  10.         int n = in.nextInt();
  11.         System.out.print("Введите числа: ");
  12.         int smin = 0;
  13.         int min = 999;
  14.  
  15.         for(int counter = 0; counter < n; counter++){
  16.             int x = in.nextInt();
  17.             if (x < min) {
  18.                 min = x;
  19.             }
  20.             if(x < min && x < smin){
  21.                 min = x;
  22.             }else if(x > min && n > x) {
  23.                 smin = x;
  24.             }
  25.         }
  26.  
  27.         System.out.print("Второй минимум: " + smin);
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement