skipter

Smallest Number - Java Basics

Apr 4th, 2017
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) throws InterruptedException {
  5.         Scanner input = new Scanner(System.in);
  6.         int n = Integer.parseInt(input.nextLine());
  7.         int minNum = Integer.MAX_VALUE;
  8.  
  9.         for (int i = 0; i < n; i++) {
  10.  
  11.             int currentNumber = Integer.parseInt(input.nextLine());
  12.  
  13.             if (currentNumber <= minNum) {
  14.                 minNum = currentNumber ;
  15.             }
  16.  
  17.         }
  18.         System.out.println(minNum);
  19.  
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment