F
F
FahrenheitRUS2015-04-29 12:38:29
Arrays
FahrenheitRUS, 2015-04-29 12:38:29

How to compare 2 arrays with 1 line?

Hello!
I am doing a C++ programming course. Do a Japanese crossword puzzle. Basic programming level.
There are buttons that can have 2 statuses - Black and White (shaded or unshaded cell), Checked (custom mark "do not paint over" - not implemented yet).
1. Using the conditions, I fill the player's result array:
if (this->button6->Text=="White")
usermass[5]=2;
else if (this->button6->Text=="Black")
usermass[5]=1;
2. I sew a standard into the program code, with which the player's array must match 100%.
int must2bmass1[9] = {1,2,1,2,2,2,1,2,1};
3. Further, according to my logic, it is necessary to compare the results of the player with the standard, depending on this, a victory is reported or it is recommended to think again.
if (falsehappen == 0)
this->button10->Text="YEAH";
else
this->button10->Text="TRY AGAIN LOL";
falsehappen - mismatch counter, 0 by default. Array elements are iterated over, if mismatch occurs ++;
The code turns out very dumb, but working. Therefore, I ask you to help make it at least a little more elegant and advanced)) I ask you to help implement array comparison without enumeration, in one line that can be inserted inside the if condition.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey K, 2015-04-29
@mututunus

Write a function to compare arrays.

S
SHVV, 2015-04-29
@SHVV

You can use memcmp, but it's better to write a separate function, as advised.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question