generated = (rand() % 11);
cout << "GUESS THE NUMBER 10 TIMES" << endl;
for (int i = 0; i < 10; i++) {
cin >> guesses[i];
if (generated == guesses[i]) {
cout << "CONGRATS ! YOU HAVE FOUND THE CORRECT NUMBER ! " << generated << endl;
restart();
break;
}
}
cout << "HERE ARE YOUR GUESSES:" << endl;
for (int k = 0; k < 10; k++) {
cout << guesses[k] << endl;
}
If the array isn't filled up, the output gives me the guessed values and then in the empty slots are random numbers. Is there a way to clear or delete the untouched slots?
Aucun commentaire:
Enregistrer un commentaire