Large tic-tac-toe game

Hello. I need a help.
There is a task for the last year Ukrainian school programming competition.

To create a program which takes an input where is 2 number (height and width of a game field). Then next lines the program takes an appearance of that field, where 'X' symbol is a barrier, '?' it's an unknown label. And '+' or '-' these are like 'X' and 'O' in a real game. The issue is to return this field without any '?' instead of '?' it must be '+' or '-' and it has to be eventually no winner and no losser. When you're a winner then it has to be more your labels in a filled row or a filled column. That's probably all. I rewrote lots of C++ code but it work only a little. I hope you'll help me:)
Here is exaples:

Input
3 4
+?XX
?X?X
X??X
Output:
+-XX
-X+X
X+-X
Input:
6 4
X??X
X?-X
?+??
-???
?XX+
?XX?
Output:
X-+X
X+-X
++--
--++
-XX+
+XX-
Last edited on
Does anybody know how to solve it?
@Ivan Klimov

Why don't you show us the code you've written that works only a little, and maybe someone here can figure out WHY it only works a little.
@whitenite1
I could show you my code, but I'm sure that's all wrong, because there should be some simple logic to solve this. I've done a two-dimensional array and just checked every row and column (rows and columns where instead of '?' it's doubtlessly '-' or '+' or both ++ or --). The code is about 200 lines, there are many 'for' loops. If you don't know how to solve it, I won't annoy you. I'm just preparing to the high programming competition and there are tasks like this. I've done a lot of similar tasks without any help but this task is so annoying.
@Ivan Klimov

( Program removed.. )
NOTE: Not even close to what OP wanted, but then, things wanted kept changing, or added to. Nowhere in the original help request was it mentioned that the user inputs and no random. Nowhere is it mentioned either, when the ?'s comes along. So, I'm giving up on solving, and deleted this program and the source on my HD.

Good luck Ivan..
Last edited on
@whitenite1

Excuse me, but eventually using this code there is a winner but the issue is to print an output and there must be no winner and no loser (numbers of '+' and '-' equal in each row and column)

For example:
Simple:
2 2
??
??

Output:
+-
-+

or

-+
+-

But never
++
-+
Or
-+
-+

It was a very simple example

When that's a tie, then a number of + and - in each row and column is divided by two, because if it is not so, then for example:
4 2
??x?
????
Here the first row ??x? Has 3 unknown positions but always here must be a winner.
And the third column has 1 position.
Last edited on
The task ensures that an input always is like I described above
And a user has to enter a field by himself:)
No random.

And the size of a field is N, M (2 ≤ N, M ≤ 80)
Topic archived. No new replies allowed.