Skip to content

Instantly share code, notes, and snippets.

@torazuka
Created August 24, 2011 11:49
Show Gist options
  • Select an option

  • Save torazuka/1167902 to your computer and use it in GitHub Desktop.

Select an option

Save torazuka/1167902 to your computer and use it in GitHub Desktop.
Chapter04_6_drill_PPPC++
#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