Print all 8 patterns using the if statement

Asked 1 years ago, Updated 1 years ago, 360 views

It's java. Use the if statement

XOXOXO---
XOXOXOX--
XOXOXO-X-
XOXOXO--X
XOXOXOOX-
XOXOXO-XO
XOXOXOOXX
XOXOXOXXO

I want to print all eight of these, but if I enter all nine spaces with "-" that is, -----, how do I write an if statement to print all eight of these?

Thank you

java an-if-statement print

2022-12-20 00:50

1 Answers

I understand after seeing it about four times, but the question is like a beggar's shoe.

The question you received is asking this.

I'm playing the TikTakTok game now. It already has a total of six moves. Now it's X's turn. Once you print out the current situation, print out all the progress developments of each game from that situation in every case where the game ends.

A string of 9 characters is used to indicate the progress. The index ((a-1)*3)+(b-1) of the string indicates the number placed in row a and row b of the game board. For example, the characters in index 0 are the numbers in row 1 and row 1, and the characters in index 8 are the numbers in column 3 of row 3. Any unnumbered space is marked with -.

Then the first line is actually that expression (like a beggar's foot) of playing the TikTaekto game up to here.

X O X
O X O
- - -

And if you look at the second row, obviously in that situation, the TikTaekTok game ends with X's victory.

X O X
O X O
X - -

But in the third row, the TikTaekto game is not over yet.

X O X
O X O
- - X -

Then what should we do? If you look at the model answer, you can see the output of putting an X in the space that you haven't filled in yet.

X O X
O X O
- - - X

If you think about when you came all the way here, there's only one case where the game isn't over yet. We put the X in the middle. Now the problem changes like this.

I'm playing the TikTakTok game now. It already has a total of seven moves. Now it's O's turn. Print out all progress developments for each game ending from that situation.

It changed a bit. I think I've seen it before, right? I'll talk about this again later. Anyway, what else does it say I need to print out?

X O X
O X O
OX - (*It's still a win-loss situation, so let's move on

X O X
O X O
- XX (*It's still a win-loss situation, so let's move on)

Now the problem changes like this. There are two cases where the game is not over.

I'm playing the TikTakTok game now. It already has a total of eight moves. Now it's X's turn. Print out all progress developments for each game ending from that situation.

I'll skip the rest. If you count them all, it's eight lines. Here's why there are 8 things to print out.

If the task of "something has changed a little and I think I've seen it a lot" is happening because of the task of "something has changed a little and I think I've seen it a lot somewhere," then that task is recursive with a very high probability. I can't explain what recursion is, but I think I've done it roughly.

You have to use your brain well while looking at your back. So it's not an implementation where you can ask someone to code for you. It's quite difficult to understand or fix the recursive implementation made by others. In the first place, the question was, "Is the game a shobu?"I've got to make a decision. I need to pay attention to the recursive print order. And so on and so forth, there are more headaches than the reflexes themselves.

"Why did this assignment ask me to print this out?" "What does this have to do with TikTakTok?" I wondered, but I came here without realizing it. I wonder how far you've been curious. It's not even my assignment, so you're wondering why I was so curious about this. That's why I'm leaving now Don't lose your inquiring mind! Fighting!


2022-12-20 02:07

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.