設計一程式,當輸入任意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;
}
5 7 1 12
請依序輸入四個整數: 最大值為:12
| ID | User | Problem | Subject | Hit | Post Date |
沒有發現任何「解題報告」 |
|||||