fork(2) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <vector>
  4. #include <algorithm>
  5. using std::cout;
  6. using std::cin;
  7. using std::vector;
  8. using std::endl;
  9. using std::sort;
  10.  
  11.  
  12.  
  13. int main(){
  14. vector<double> notes;
  15. cout<<"Enter some notes and hit ctrl+D followed by an <enter> to stop: ";
  16. double input;
  17. while(cin >> input){
  18. notes.push_back(input);
  19. }
  20.  
  21. cout<<endl<<"Entered notes: ";
  22. for(int i=0; i<notes.size(); ++i){
  23. cout<<notes[i]<<" ";
  24. }
  25. sort(notes.begin(), notes.end());
  26.  
  27. cout<<endl<<"Min: "<<notes[0]<<" Max: "<<notes[notes.size()-1];
  28.  
  29.  
  30.  
  31.  
  32. }
Success #stdin #stdout 0s 3436KB
stdin
123.45
67.89
stdout
Enter some notes and hit ctrl+D followed by an <enter> to stop: 
Entered notes: 123.45 67.89 
Min: 67.89 Max: 123.45