AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > C++

引导C++初学者走进ACM

51自学网 http://www.wanshiok.com

Time Limit:3s       Memory Limit:8192K     In/Out:Stdin/stdout

Given a series of integer, find the maximum number.

Input
Multi-case. The first line gives count n (n < 100) of this array. n=0 means end of input. There are one integer in the next n lines.

Output
For each case, output the maximum number in one line.

Sample Input
3
1 4 5
0
Sample Output
5

程序代码:


#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
int n;
cin>>n;
while (n != 0)
{
  if (n >= 100) exit(-1);
            int *a = new int[n];
  for (int i=0; i<n; ++i)
   cin>>a[i];
  cout<<*max_element(a,a+n)<<endl;
  delete []a;
  cin>>n;
}
return 0;
}


Code:304B          Time(s):0.00         Mem(k):804/1632

 
 

上一篇:C++程序设计从零开始(一)  下一篇:WinHelp&nbsp;API命令方法