#33279: _C++


50915130@gm.nfu.edu.tw (丁丁)

學校 : 國立虎尾科技大學
編號 : 218566
來源 : [45.144.227.36]
最後登入時間 :
2024-04-02 02:47:02

include <iostream>
using namespace std;
int main(){
    int t = 0,ts=1;
    cin >>t;
    while(t--){
        int j=0;
        cin >>j;
        j--;
        int tower=0; //第一個塔的高度
        cin >> tower; 
        int high=0,low=0;
        while(j--){
            int next; //下一個塔的高度
            cin >> next; 
            if(tower<next) //如果比較高 high++
                high++;
            if(tower>next) //如果比較矮 low++
                low++;
            tower=next;    //到下一個塔上,一樣高直接到下一個塔

       }
        cout << "Case " << ts <<": " <<high<<" "<<low<<endl; // 輸出
        ts++; //Case ts: high low\r\n

   }
}

#38475: Re: C++


a0978435327@gmail.com (Zi-ke_Liao)

學校 : 國立虎尾科技大學
編號 : 184991
來源 : [36.233.10.177]
最後登入時間 :
2025-06-24 20:16:21

include
using namespace std;
int main(){
    int t = 0,ts=1;
    cin >>t;
    while(t--){
        int j=0;
        cin >>j;
        j--;
        int tower=0; //第一個塔的高度
        cin >> tower; 
        int high=0,low=0;
        while(j--){
            int next; //下一個塔的高度
            cin >> next; 
            if(tower
                high++;
            if(tower>next) //如果比較矮 low++
                low++;
            tower=next;    //到下一個塔上,一樣高直接到下一個塔

       }
        cout << "Case " << ts <<": " <
        ts++; //Case ts: high low\r\n

   }
}


???