- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main(void){
- int number[4];
-
- for(int i = 1; i <= 4; i++){
- cout << "請輸入第" << i << "個數字" << endl;
- cin >> number[i-1];
- }
-
- int max= 0;
- int min= number[0];
- for(int i = 1; i <= 4; i++){
- if(max < number[i-1]){
- max = number[i-1];
- }
- if(min > number[i-1]){
- min = number[i-1];
- }
- }
-
- cout << max << endl;
- cout << min << endl;
-
- system("pause");
- return 0;
- }
複製代碼 |