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  
2/2 首页 上一页 1 2 |