int main() { srand(time(NULL)); int q[3]; int start = 0, ends = 0; cout << "Enter: " << endl; for (int h = 0; h < 3; h++) { int a; a = rand() % 10; q[start++] = a; } cout << "First: " << q[start - 1] << endl; cout << "Second: " << q[start - 2] << endl; cout << "Last: " << q[ends]; cout << endl; // Это должно высвечивать только когда я нажму Enter if (q[start - 1] == q[start - 2]) { cout << "q[start - 1] == q[start - 2]" << endl; } if (q[start - 1] == q[ends]) { cout << "q[start - 1] == q[ends]" << endl; } if (q[start - 2] == q[ends]) { cout << "q[start - 2] == q[ends]" << endl; } if (q[start - 1] == q[start - 2] == q[ends]) { cout << "WOW!!!" << endl; } if (start != ends) cout << "Queue is empy!"; return 0; } 

Closed due to the fact that the essence of the question is incomprehensible by the participants insolor , αλεχολυτ , AK , 0xdb , user192664 24 Oct '18 at 10:05 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • And now what is happening? - Enikeyschik

1 answer 1

For example:

 printf("\nPress Enter..."); char anykey[120]; gets_s(anykey, sizeof(anykey)); 

The input will be completed by pressing Enter, but the buffer should be done with a margin, because there will be an error during the overflow. You can handle the error yourself by setting your own constraint handler , but it's easier to make a larger buffer.

(corrected the error, was too lazy to check the code)