Can you help me organize my function (for loops) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can you help me organize my function (for loops)

Hello! So I created a Tic Tac Toe code and I decided to make it look better so I changed the names, created valid input and more. But I relized that I have like 100 line code that could be done in 50 but I really couldn't get the code to work with for loops. I want to replace the "move" function so I will be able to create for example 2 loops and not just type for example game[0][0] == 'X' and so on and so forth if someone can help me figure this out I'll be greatful. Here's the code: https://code.sololearn.com/cOcerAjfI9le/#cpp I tried doing this but the output is just the game prints 'X' all over the screen: https://code.sololearn.com/cyt6F828N6r3/#cpp p.s I will be happy for other title if you have in mind

30th Jul 2019, 7:44 AM
Cout
Cout - avatar
3 Answers
+ 2
~ swim ~ I meam the win in total is pretty much the same amount of lines when you look on it pretty much although yours is much better and thank you so much I didn't test it yet but looks very good
30th Jul 2019, 5:40 PM
Cout
Cout - avatar
+ 1
@~ swim ~ I understand what you did but I don't understand why is it when i do int row = (inputPlayerMove - 1) / 3; it gives me rows and int col = (inputPlayerMove - 1) % 3; gives me col
30th Jul 2019, 5:51 PM
Cout
Cout - avatar
+ 1
~ swim ~ I got it thanks
30th Jul 2019, 8:23 PM
Cout
Cout - avatar