Java 二级操作题 从键盘输入五个正整数 输出最大值

import java.io.*;
public class Java_1 {
     public static void main(String[ ] args) throws IOException {
            InputStreamReader ir;
            BufferedReader in;
            int max, x;
            String data;

            max = 0;
            ir = new InputStreamReader(System.in);
            in = new BufferedReader(ir);
            System.out.println("请输入5个正整数:");
            //*********Found**********
            for (int i = 1;i<5; i++) {
                data = in.readLine();
                //*********Found**********
                x = Integer.parseInt(data);
                if ( max < x )
                    //*********Found**********
                    max=x;
            }
            System.out.println("输入的最大值是 "+ max);
        }
}
 

猜你喜欢

转载自blog.csdn.net/qq_38945163/article/details/81315916