- /*4.輸入四個數字,找出最大與最小值。*/
- #include <iostream>
- 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 mini = 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;
- cin >> mini;
-
- system("pause");
- return 0;
- }
複製代碼 |