Почему выражение обновления цикла for (i + 2) создает бесконечный цикл? [дубликат] ⇐ C++
Почему выражение обновления цикла for (i + 2) создает бесконечный цикл? [дубликат]
I was doing an exercise in my textbook that asked us to output a vector's elements at even indices separated by asterisks. Then on a newline, do the same thing with the odd indices. So, if the vector contained 10 20 30 40 50 60, the output should be:
10*30*50* 20*40*60* The textbook gives us the starting code:
#include #include using namespace std; int main() { int numStudents; int i; cin >> numStudents; vector idNumbers(numStudents); for (i = 0; i < idNumbers.size(); ++i) { cin >> idNumbers.at(i); } And we need to finish the code. My initial solution was:
// Even indices for (i = 0; i < idNumbers.size(); (i + 2)) { cout
Источник: https://stackoverflow.com/questions/781 ... inite-loop
I was doing an exercise in my textbook that asked us to output a vector's elements at even indices separated by asterisks. Then on a newline, do the same thing with the odd indices. So, if the vector contained 10 20 30 40 50 60, the output should be:
10*30*50* 20*40*60* The textbook gives us the starting code:
#include #include using namespace std; int main() { int numStudents; int i; cin >> numStudents; vector idNumbers(numStudents); for (i = 0; i < idNumbers.size(); ++i) { cin >> idNumbers.at(i); } And we need to finish the code. My initial solution was:
// Even indices for (i = 0; i < idNumbers.size(); (i + 2)) { cout
Источник: https://stackoverflow.com/questions/781 ... inite-loop
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
У меня проблема с циклом For и словарем в Godot 4, где он создает бесконечный цикл.
Anonymous » » в форуме Python - 0 Ответы
- 12 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Почему эта программа создает бесконечный цикл, используя LOOP вокруг SYSCALL?
Anonymous » » в форуме Linux - 0 Ответы
- 11 Просмотры
-
Последнее сообщение Anonymous
-