jeudi 20 avril 2017

Whole Array as Condition in C++

I'm doing a Game of Fifteen sort of thing and I'm stuck on the syntax of arrays regarding the winning condition.

This is how I initialized the tiles:

string tile[4][4] = { { "15","14","13","12" },{ "11","10","9","8" },{ 
"7","6","5","4" },{ "3","1","2"," _" } };

This is the winning condition I want (basically all tiles in order):

while (tile[4][4] != { {"1", "2", "3", "4"}, { "5","6","7","8" }, { 
"9","10","11","12" }, { "13","14","15","_" } }) {...}

My problem is that the second one results in a syntax error. Probably caused by the brackets specifying the position of a value instead of the size like the first initialization. I want the condition to be the whole array instead of just a specific value from that array.

I've tried doing empty brackets with the condition but again, to no avail.

How do I express the whole array as a condition?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire