题目1046:求最大值

题目1046:求最大值

时间限制:秒内存限制:32 

题目描述:

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

输入:

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

输出:

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

样例输入:

10 22 23 152 65 79 85 96 32 1

样例输出:

max=152

 */

/**************************************************************

Problem: 1046

User: watchfree

Language: Java

Result: Accepted

Time:80 ms

Memory:15472 kb

****************************************************************/

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int max=-100000;
            int temp=0;
            for(int i=0;i<10;i++){
                temp=sc.nextInt();
                if(temp>max)max=temp;
            }
            System.out.println("max="+max);
        }
        sc.close();
    }

}
原文地址:https://www.cnblogs.com/watchfree/p/5329142.html