HDU 2071 Max Num

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;
}

  

上一篇:BIP_开发案例06_以RB.RDF为数据源BIP.RTF为模板的简单例子(案例)


下一篇:Android JNI programming demo with Eclipse