九度OJ--1046

来源:互联网 发布:小学生必知科普知识 编辑:程序博客网 时间:2024/04/30 07:09

http://ac.jobdu.com/problem.php?pid=1046

题目描述:

输入10个数,要求输出其中的最大值。

输入:

测试数据有多组,每组10个数。

输出:

对于每组输入,请输出其最大值(有回车)。

样例输入:
10 22 23 152 65 79 85 96 32 1
样例输出:
max=152
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int max = -1000000000;
            for (int i = 0; i < 10; i++) {
                int t = sc.nextInt();
                if (max < t)
                    max = t;
            }
            System.out.println("max=" + max);
        }
    }
 
}
0 0