有没有大佬帮忙看看,程序为什么能运行但报错不出结果。

有没有大佬帮忙看看,程序为什么能运行但报错不出结果。

问题描述:

package zh.codegym.task.task05.task0532;

import java.util.Scanner;
/*
有关算法的任务
*/

public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int i;

    if (N > 0) {
        int max = 0;

        for (i = 1; i <= N; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            max = a < b ? a : b;


        }
        System.out.println(max);
    }
    if(N<=0){
        System.out.println();
    }

}

}
编写程序,使其:
1. 从控制台读取数字 N(必须大于 0)
2. 从控制台读取 N 个数字
3.显示 N 个输入数字中的最大值。

要求:
1.程序应从键盘读取这些数字。
2.程序必须在屏幕上显示一个数字。
3.该类必须包含 public static void main 方法。
4.不要向 Solution 类添加新方法。
5.程序应显示 N 个输入数字中的最大值。
6.如果 N 小于或等于 0,程序不应显示任何内容。
绝望到家了,啥都满足了。就是没满足条件5,气死我鸟了。有大哥告诉我问题出在哪了么!!

import java.util.Scanner;

public class Solution {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        if(N > 0){
            int max = scan.nextInt();   //假设第一个数是最大的
            int i = 1;
            while(i < N){
                int next = scan.nextInt();  //不断读取下一个数
                i++;
                if(max < next){
                    max = next;     //将读到的数与当前最大值比较,维护最大值变量
                }
            }
            System.out.println(max);
        }
        scan.close();
    }
}