daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jun 14th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top