I have been recently solving a coding question that requires an user to input a 3xN matrix that consists of only '.', '*', and '#'. Then there are some patterns mentioned in the question that is taken care of in the code below, but there's a problem. The problem is I have if-else statements inside a for loop. But when an if block matches it does prints out the requires character but the for loop terminates. I want the for loop to continue till 'N'.
    #include<bits/stdc++.h>
    #include<string.h>
    using namespace std;
    int main(){
     int N;
     cin >> N;
     if(N>=3 && N<=100000){
        char matrix[3][N];
        string p;
        for(int i=0;i<3;i++)
            for(int j=0;j<N;j++)
                cin >> matrix[i][j];
                
        for(int i=0; i<N; i+=2){
            if(matrix[0][i] == '.')
                continue;
            else if(matrix[0][i] == '#'){
                cout << '#';
                continue;
            } else if(matrix[0][i] == '*'){
                //E
                if((i+2)<N && matrix[0][i+1]=='*' && matrix[0][i+2]=='*' && matrix[1][i]=='*' && 
               matrix[1][i+1]=='*' && matrix[1][i+2]=='*' && matrix[2][i]=='*' && matrix[2][i+1]=='*' && 
               matrix[2][i+2]=='*'){
                    p +='E';
                    continue;
                //A
                } else if((i+2)<N && matrix[0][i+1]=='.' && matrix[1][i]=='*' && matrix[1][i+1]=='*' && 
               matrix[1][i+2]=='*' && matrix[2][i]=='*' && matrix[2][i+1]=='.' && matrix[2][i+2]=='*'){
                    p += 'A';
                    continue;
                //I
                } else if((i+2)<N && matrix[0][i+1]=='*' && matrix[0][i+2]=='*' && matrix[1][i]=='.' && 
                   matrix[1][i+1]=='*' && matrix[1][i+2]=='.' && matrix[2][i]=='*' && matrix[2][i+1]=='*' 
               && matrix[2][i+2]=='*'){                 
                    p += 'I';
                    continue;
                //O
                } else if((i+2)<N && matrix[0][i+1]=='*' && matrix[0][i+2]=='*' && matrix[1][i]=='*' && 
               matrix[1][i+1]=='.' && matrix[1][i+2]=='*' && matrix[2][i]=='*' && matrix[2][i+1]=='*' && 
               matrix[2][i+2]=='*'){
                    p += 'O';
                    continue;
                //U
                } else if((i+2)<N && matrix[2][i]=='*' && matrix[2][i+1]=='*' && matrix[2][i+2]=='*' && 
                matrix[0][i+1]=='.' && matrix[0][i+2]=='*' && matrix[1][i]=='*' && matrix[1][i+1]=='.' && 
                matrix[1][i+2]=='*'){
                    p += 'U';
                    continue;
                } else
                    continue;
            } else {
                cout << "Invalid Input";
                continue;
            }
        }
        cout << p;
    } else {
        cout << "Invalid Input";
    }
}
Input: * * * #
       * * * #
       * * * #
Output : E
What should it print (Correct output): E#
 
     
     
    