Advertisement
makispaiktis

Statistics for Degrees

Oct 29th, 2019 (edited)
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     cout << "Give me the degrees to find some statistics results." << endl;
  10.     cout << "In the following step, you have to write down the degrees and press enter to confirm.";
  11.     cout << "In order to stop the process, you have to type '1000' or sth bigger than 1000. Of course this degree will not count in the statistics process." << endl << endl;
  12.  
  13.     vector <double> degrees = vector <double> ();
  14.     double degree = -1000000;
  15.     // The 1st value of degree is only to continue into the while-loop: This value is not passed in the vector, because the 1st thing going inside the loop is to read the user's input degree
  16.     while(degree < 1000){
  17.         cout << "Degree: ";
  18.         cin >> degree;
  19.         cout << endl;
  20.         degrees.push_back(degree);
  21.     }
  22.     // After the end of the loop, we have such a big value (appropriate for the exit) and we have to remove it from the vector
  23.     degrees.erase(degrees.end() - 1);
  24.     for(int i=0; i<degrees.size(); i++){
  25.         cout << degrees[i] << endl;
  26.     }
  27.     return 0;
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement