fork download
  1. //@Author Damien Bell
  2. #include <iostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.  
  9. vector<int> vInt;
  10. int x;
  11. int y;
  12.  
  13. cout << "How many people are playing the game? ";
  14. cin >> x;
  15.  
  16. for (int i=0; i<x; i++){
  17. cout <<"\nEnter the score for player " << i << ": ";
  18. cin >>y;
  19. vInt.push_back(y);
  20. }
  21.  
  22. for (int i=0; i<vInt.size(); i++){
  23. cout <<vInt[i] << endl;
  24. }
  25.  
  26. //Make an array of 10 numbers, then put them in reverse order into a vector, using a for loop.
  27.  
  28.  
  29. //for (int i=0; i<10; i++){
  30. // vInt.push_back(i);
  31. // }
  32.  
  33. // for (int i=0; i < vInt.size(); i++){
  34. // cout << vInt[i] <<endl;
  35. // }
  36.  
  37.  
  38.  
  39. return 0;
  40. }
  41.  
stdin
5
0
1
2
3
4
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:22: warning: comparison between signed and unsigned integer expressions
stdout
How many people are playing the game? 
Enter the score for player 0:  
Enter the score for player 1:  
Enter the score for player 2:  
Enter the score for player 3:  
Enter the score for player 4:  0
1
2
3
4