fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int choose()
  7. {
  8. cout << "Enter your choice, 1,2 or 3:\n";
  9. int x;
  10. cin >> x;
  11. return x;
  12. }
  13.  
  14. int main()
  15. {
  16. vector <int> vote;
  17. for(int i=0; i<10; ++i)
  18. {
  19. int choice = choose();
  20. vote.push_back(choice);
  21. }
  22. cout << vote.size() << '\n';
  23. }
  24.  
Success #stdin #stdout 0s 3032KB
stdin
1 2 3 1 2
1 2 3 1 2
stdout
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
Enter your choice, 1,2 or 3:
10