Skip to content

Instantly share code, notes, and snippets.

@ampulhetadosaber
Created August 26, 2020 23:57
Show Gist options
  • Save ampulhetadosaber/f760860f1b428621314f57e5308e1c96 to your computer and use it in GitHub Desktop.
Save ampulhetadosaber/f760860f1b428621314f57e5308e1c96 to your computer and use it in GitHub Desktop.
vector<int> I;
I.push_back(10);
I.push_back(17);
I.push_back(0);
I.push_back(-15);
for(int i = 0; i < I.size() ; i++)
{
// seu código
}
// Do c++11 em diante, também podemos fazer:
for(auto u: I)
{
// seu código
// Vale lembrar que ao fazermos isso, u vai guardar os valores, mas não conseguimos
// saber em qual iteração do for estamos, para isso precisariamos percorrer o vector
// do jeito acima
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment