Another approach to solving this problem is possible. You can use an early exit from the loop if the required value is found. In C++, the break statement is used to break out of a loop;
X
Not found
1000 ms 256 Mb Rules for program design and list of errors in automatic problem checking