• codeforces水题100道 第十九题 Codeforces Round #109 (Div. 2) A. I_love_%username% (brute force)


    题目链接:http://www.codeforces.com/problemset/problem/155/A
    题意:找到当前最大值或者最小值出现的次数。“当前”的意思差不多是a[i]大于所有a[j](j小于i)或者大于所有a[j]。
    C++代码:

    #include <iostream>
    using namespace std;
    int n, a[1100];
    int main()
    {
        cin >> n;
        for (int i = 0; i < n; i++)
            cin >> a[i];
        int Low = a[0], High = a[0], cnt = 0;
        for (int i = 1; i < n; i ++)
        {
            if (a[i] > High)
            {
                High = a[i];
                cnt ++;
            }
            else if (a[i] < Low)
            {
                Low = a[i];
                cnt ++;
            }
        }
        cout << cnt;
        return 0;
    }
    C++
  • 相关阅读:
    PowerDesigner导出word表结构
    Java
    Java
    Java
    Java
    Java
    Java
    Java
    Java
    Java
  • 原文地址:https://www.cnblogs.com/moonlightpoet/p/5689338.html
Copyright © 2020-2023  润新知