I'm just starting to learn c++ and I'm having trouble understanding the boolean function.
srand(time(0)); for(ctr = 0; ctr < amt; ctr++){ do{ unique = false; let[ctr] = (char)(rand() % 26 + 65); for(check = 0; check < ctr; check++){ if(let[ctr] == let[unique]){ unique = true; } } }while(unique); cout<<let[ctr]<<" "; } Its suppose to randomly generate a set amount of letters and the do-while makes sure that there isn't a duplicate letter. I can't seem to understand how does it know if there is a duplicate letter and how does it eliminate it.
https://stackoverflow.com/questions/67042133/trouble-understanding-the-boolean-function April 11, 2021 at 02:39PM
没有评论:
发表评论