c011: 陣列宣告
Tags : C++
Accepted rate : 1人/1人 ( 100% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-11-24 10:28

Content

設計一程式,當輸入任意4 個整數時,會於畫面中列印出最大值。

#include <iostream>
using namespace std;
int main() {
     int a[4];
     cout << "請依序輸入四個整數:" << endl;
     cin >> a[0] >> a[1] >> a[2] >> a[3];
     int Max = a[0];
     for(int i=1;i<4;i++)  {
          if(a[i]>Max)  {
            Max = a[i];
          }
      }
      cout << "最大值為:" << Max;
      return 0;
}

Input
Output
Sample Input #1
5 7 1 12
Sample Output #1
請依序輸入四個整數:
最大值為:12
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (100%): 1.0s , <1K
Hint :
Tags:
C++
出處:
育達技高資訊科技 [管理者: zero(育達管理員) ]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」