fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main() {
  7. //Our temp vector. It'll hold a line worth of ints
  8. vector<int> line(5);
  9.  
  10. while(true) { //one loop = one line
  11. //Loop and read 5 ints (one line's worth) into the vector
  12. for(int x = 0; x < 5 && cin >> line.at(x); x++) { }
  13. if(!cin) { break; } //if we read through everything, we're done!
  14. //find the biggest value in the vector
  15. int biggest = *max_element(line.begin(), line.end());
  16. //Do some things with it...
  17. cout << "Biggest is: " << biggest << endl;
  18. }
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 15240KB
stdin
-50 8 5 56 3 
-70 21 95 47 -40 
-74 51 23 46 13 
52 -14 81 89 38 
70 -42 9 28 -5 
53 -88 75 16 32 
-43 16 90 63 -29 
-58 43 42 -63 -10 
-98 -87 91 25 9 
-47 -24 95 84 -86 
stdout
Biggest is: 56
Biggest is: 95
Biggest is: 51
Biggest is: 89
Biggest is: 70
Biggest is: 75
Biggest is: 90
Biggest is: 43
Biggest is: 91
Biggest is: 95