3070 n个整数“打擂台” 循环

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int i = 1,n,maxx = -9999999; //初始化最大值maxx为负数 
    cin >> n;
    while(i <= n)
    {
        int x; cin >> x;
        if(x > maxx) maxx = x; //x更大,将maxx更新为x 
        i++;
    }
    cout << maxx;
    return 0;
}

 

posted @ 2024-10-23 13:37  CRt0729  阅读(8)  评论(0编辑  收藏  举报