The task is to make a program that converts the incoming array, replacing two consecutive zeroes (00) by 1. For example, 10010 by 1110
#include <iostream> #include <stdlib.h> using namespace std; int main() { int in[8], out[8], i; cout << "In:" << endl; //Входящий поток for (i=0;i<8;i++) //Ввод потока { cout << "In[" << i << "]="; cin >> in[i]; if (in[i]!=0 && in[i]!= 1) { cout << "Incorrect In. Only 0 and 1 permitted." << endl; exit(0); } } cout << endl; for (i=0; i<8; i++) cout << in[i]; cout << endl << endl << "Out:" << endl; for (i=0; i<8; i++) { int j=0; if(in[i]==1) {out[j]=1; j++;} if(in[i]==0) { if (in[i+1]==1) { out[j]=0; j++; } if (in[i+1]==0) { out[j]=1; j++; i++; //Где-то тут жесткий косяк } } } cout << endl; for (i=0; i<j; i++) cout << out[i]; cout << endl; return 0; } The output ignores my i ++ in the line with the comment about the joint, does not look very 
The question is obvious , why is i ++ ignored and how to make it work?
Thank you in advance.