九度oj 题目1046:求最大值

题目1046:求最大值

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:11782

解决:4789

题目描述:

输入10个数,要求输出其中的最大值。

输入:

测试数据有多组,每组10个数。

输出:

对于每组输入,请输出其最大值(有回车)。

样例输入:
10 22 23 152 65 79 85 96 32 1
样例输出:
max=152

 1 #include <iostream>
 2 #include <vector>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 int main(){
 7     int t;
 8     vector<int> v;
 9     while(cin >> t){
10         v.push_back(t);
11         for(int i = 0; i < 9; i++){
12             cin >> t;
13             v.push_back(t);
14         }
15         cout << "max=" << *max_element(v.begin(), v.end()) << endl;
16         v.clear();
17     }
18 }
 1 #include <stdio.h>
 2 
 3 int main(){
 4     int temp, max, i;
 5     while(scanf("%d", &temp) != EOF){
 6         max = temp;
 7         for(i = 0; i < 9; i++){
 8             scanf("%d", &temp);
 9             if(temp > max)
10                 max = temp;
11         }
12         printf("max=%d\n", max);
13     }
14     return 0;
15 }

 

 

转载于:https://www.cnblogs.com/qinduanyinghua/p/6437625.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值