码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2071 Max Num

时间:2018-06-25 21:47:43      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:find   class   integer   out   std   div   names   NPU   return   

http://acm.hdu.edu.cn/showproblem.php?pid=2071

 

 

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
2
3 170.00 165.00 180.00
4 165.00 182.00 172.00 160.00
 
Sample Output
180.00
182.00
 
代码:
#include <bits/stdc++.h>

using namespace std;
double a[111];
int main()
{
    int M;
    cin>>M;
    for(int i=1;i<=M;i++)
    {
       int n;
       cin>>n;
       for(int i=1;i<=n;i++)
       {
           cin>>a[i];
           for(int j=i;j>=2;j--)
           {
               if(a[j]<=a[j-1])
                swap(a[j],a[j-1]);
           }
       }
       for(int i=1;i<=n;i++)
       {
           if(i==n)
           printf("%.2f\n",a[n]);
       }
    }
    return 0;
}

  

HDU 2071 Max Num

标签:find   class   integer   out   std   div   names   NPU   return   

原文地址:https://www.cnblogs.com/zlrrrr/p/9226212.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!