HDU——2071Max Num

来源:互联网 发布:淘宝转让合法吗 编辑:程序博客网 时间:2024/06/07 01:12

Max Num

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 20234    Accepted Submission(s): 12088


Problem Description
There are some students in a class, Can you help teacher find the highest student .
 

Input
There are some cases. The first line contains an integer t, indicate the cases; Each case have an integer n ( 1 ≤ n ≤ 100 ) , followed n students’ height.
 

Output
For each case output the highest height, the height to two decimal plases;
 

Sample Input
23 170.00 165.00 180.004 165.00 182.00 172.00 160.00
 

Sample Output
180.00182.00
 

Author
Lily
 

Source
浙江工业大学网络选拔赛


原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2071

AC代码:
import java.util.*;class Main{    public static void main(String args[])    {        Scanner sc=new Scanner(System.in);        while(sc.hasNext())        {          int n=sc.nextInt();          double[] a=new double[1000];            while(n-->0)            {                int m=sc.nextInt();                a[0]=sc.nextDouble();                double max=a[0];                for(int i=1; i<m; i++)                {                    a[i]=sc.nextDouble();                    if(a[i]>max)  max=a[i];                }                System.out.printf("%.2f",max);                System.out.println();            }        }    }}



0 0
原创粉丝点击