Lottery simulator c++
I have a lottery simulator that needs to have a random number vector as the lottery and a vector that allows user to enter 5 digits and compare the two arrays. If both vectors match it should print you win else you didn't win, all while comparing elements to see which match. My code does this, but it prints you lose after every random element as well as if the numbers match on each element. Could someone explain how I could get it to print if you win or lose after the random number vector as well as, the number of elements that match after the random number vector prints. Any advice is greatly appreciated. #include <iostream> #include <vector> #include <ctime> #include <cstdlib> using namespace std; const int size = 5; int main() { srand(time(NULL)); vector<int>lottery; vector<int>user; int guess; int count = 0; cout << " Make 5 guesses: "; for(int j = 1; j<=5; j++) { cin >> guess; } for(int i = 1; i<=5; i++) { lottery.push_back(rand() % 9 + 1); } for(int n : lottery) { if(n == guess) { count++; } user.push_back(guess); cout <<endl; if ( lottery == user) { cout << "Grand prize winner"; } else{ cout << "You didn't win, better luck next time" << endl; } cout << n << " " <<endl; cout <<"Number you got right: "<< count<< endl; } return 0; }