+ 1

Improving Game of NIM

This is my recent program for NIM game where players add up numbers until last number. Help me to improve this game. https://code.sololearn.com/crad40x2L3n8/?ref=app

19th Feb 2020, 3:11 PM
Hyper tech
Hyper tech - avatar
2 ответов
+ 1
Not much to improve but I would like to point out few things: 1) There is no need for the variables to be declared in global space. 2) All variables should be initialized. That's a good cpp practice. That would also mean that "pro" will be declared in the very beginning and not before the while loop. Initializing/declaring a variable right before it's use is Java style and is usually discouraged in C++. 3) You should read about why "using namespace std" is not a good practice. It's not a big deal for a small program like this one but for larger code "std::cout" is less error prone compared to "using namespace std" 4) Pro = pro+plu; => pro+=plu; Keep up the hard work!!!
20th Feb 2020, 7:10 PM
Steve
Steve - avatar
+ 1
Thanks Steve, Ill keep that in mind
21st Feb 2020, 3:38 AM
Hyper tech
Hyper tech - avatar