題目連結: https://zerojudge.tw/ShowProblem?problemid=d660

# 解題思路

每當我輸入一個數字比前一個數字大的話,就要 high_jump 一次,若是小於的話,則是 low_jump 一次

# 程式碼

#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;  cin>>t;
    for(int i = 1;i<=t;i++){
        int n;  cin>>n;
        int now;   cin>>now;
        int high = 0,low = 0;
        for(int j = 1,next;j<n;j++){
            cin>>next;
            if(next>now) now = next , high++;
            if(next<now) now = next , low++;
        }
        cout<<"Case "<<i<<": "<<high<<" "<<low<<endl;
    }
}
更新於 閱讀次數

用實際行動犒賞爆肝的我😀

Zrn Ye LinePay

LinePay