HOW to back for the beginning if the user press any key except 1 or 2 or 3? [closed]

Use do–while loop and set the condition to while(L != ‘1’ && L != ‘2’ && L != ‘3’);: do { L = getch(); switch (L) { case ‘1’ : system(“cls”); printf(“111111111111111”); break; case ‘2’ : system(“cls”); printf(“222222222222222”); break; case ‘3’ : system(“cls”); printf(“33333333”); break; default : sleep(0); } } while(L != ‘1’ && L … Read more

Why do I keep getting an "expected expression error" in my While Loop? [closed]

Because that is not a valid expression. Change this: while (player_bet >= 0 && <= end_money) To: while (player_bet >= 0 && player_bet <= end_money) Translation: while player-bet is 0 or bigger, and also while player-bet is end-money or smaller. Your original expression is roughly: while player_bet is zero or bigger and also while (something … Read more

My first for loop

for (int i=12; i>=1; i–) { String month; if (i<10) month= “0” + i; else month= “” + i; //You might want to do something with the variable “month” }

What is the fastest and pythonic way to generate a list [(0,0), (0,1), (0,2)…(0,100)]? [closed]

If you want a faster solution you can use itertools.repeat: from itertools import repeat: list(zip(repeat(0), range(101))) benchmark: %timeit [(0, x) for x in range(101)] # 3.64 µs ± 19.1 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each) %timeit list(zip(repeat(0), range(101))) # 2.81 µs ± 35.3 ns per loop (mean ± … Read more

my first c++ program runtime is super long like 5 – 10 minutes on a fast CPU it's a very basic c++ program [closed]

This seems like it was purposefully un-optimized. I would assume that the time constraints are coming from modding a variable 100,000,000,000 times. But wait, that is not all. Not only do you mod a variable that many times, but when a variable modded to 0, you iterate another 11 times over each char in “Hello … Read more