Created
August 24, 2011 11:49
-
-
Save torazuka/1167902 to your computer and use it in GitHub Desktop.
Chapter04_6_drill_PPPC++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "../../std_lib_facilities.h" | |
| int main(){ | |
| int count = 0; | |
| double n = 0.0; | |
| double max = 0.0; | |
| double min = 0.0; | |
| cout << "数字を1つ入力する。「|」を入力したら終了する。\n"; | |
| while(cin >> n){ | |
| if(cin.fail()){ | |
| cout << "input error. \n"; | |
| break; | |
| } | |
| if(n == '|'){ | |
| break; | |
| } | |
| if(n < min){ | |
| cout << n << " the smallest so far" << endl; | |
| min = n; | |
| } | |
| if(max < n){ | |
| cout << n << " the largest so far" << endl; | |
| max = n; | |
| } | |
| count++; | |
| if(count == 1){ | |
| max = n; | |
| min = n; | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment