题目1046:求最大值
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:11131
解决:4528
-
题目描述:
-
输入10个数,要求输出其中的最大值。
-
输入:
-
测试数据有多组,每组10个数。
-
输出:
-
对于每组输入,请输出其最大值(有回车)。
-
样例输入:
-
10 22 23 152 65 79 85 96 32 1
-
样例输出:
-
max=152
-
来源:
- 2009年哈尔滨工业大学计算机研究生机试真题
-
- 可以直接对数组用sort()进行排序,取最后的一个数为最大值。
-
-
#include <cstdio> #include <cstring> #include <cstring> #include <algorithm> #include <iostream> using namespace std; int main() { int c[10]; while(scanf("%d",&c[0])!=EOF){ for(int i=1;i<10;i++){ scanf("%d",&c[i]); } sort(c,c+10); printf("max=%d\n",c[9]); } } /************************************************************** Problem: 1046 User: th是个小屁孩 Language: C++ Result: Accepted Time:0 ms Memory:1520 kb ****************************************************************/