galinyotsev123

ProgBasicsJavaBook5.1Loops06minNumber

Jan 15th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E06minNumber {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. System.out.print("n = ");
  8. int n = scanner.nextInt();
  9.  
  10. System.out.print("Enter the numbers: ");
  11. int min = Integer.MAX_VALUE;
  12.  
  13. for (int i = 0; i < n; i++) {
  14. int num = scanner.nextInt();
  15.  
  16. if (num < min) {
  17. min = num;
  18. }
  19. }
  20. System.out.printf("%d", min);
  21.  
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment