continue statement - cppreference.com
De cppreference.com
<metanoindex/>
Usado quando a situação é diferente estranho para ignorar o resto do loop usando instruções condicionais.
Original:
Used when it is otherwise awkward to ignore the remaining portion of the loop using conditional statements.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sintaxe
continue
|
|||||||||
Explicação
Esta declaração funciona como um atalho para o final do corpo do laço encerrando.
Original:
This statement works as a shortcut to the end of the enclosing loop body.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Em caso de while ou
fazer enquanto
Original:
do-while
The text has been machine-translated via [http://translate.google.com Google Translate].
You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.
loops, a próxima instrução executada é a verificação da condição (cond_expression). Em caso de laço for, as demonstrações próximos executados são a expressão de iteração e verificação de condição (iteration_expression, cond_expression). Depois que o loop continua como normal.
Original:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Palavras-chave
Exemplo
#include <iostream> int main() { for (int i = 0; i < 10; i++) { if (i != 5) continue; std::cout << i << " "; //this statement is skipped each time i!=5 } std::cout << '\n'; for (int j = 0; j < 2; j++) { for (int k = 0; k < 5; k++) { //only this loop is affected by continue if (k == 3) continue; std::cout << j << k << " "; //this statement is skipped each time k==3 } } }
Saída:
5 00 01 02 04 10 11 12 14