Question

In a 3xn charecter array elements #,*,. are present
The stars form shapes of A,E,I,O,U or if you encounter 3 #'s in the coloumn,
it is a gallexy

Print # if you encounter
#
#
#

Print A if you encounter
.*.
***
*.*

Print E if you encounter
***
***
***

Print I if you encounter
***
.*.
***

Print O if you encounter
***
*.*
***

Print U if you encounter
*.*
*.*
***

Find the complete question here.

Solution by Sahithi Siripuram

Solution

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false); \
cin.tie(NULL); cout.tie(NULL);

int main()
{
    FIO;
    int n, i=0; cin>>n; // Input n to form a 3*n 2D character array
    char a[3][n];
    for (int i=0;i<3;i++)
        for (int j=0;j<n;j++)
            cin>>a[i][j];  //Input the charecters into the array
    while (i<n)
      //initialize the value of i to the starting position
      //and run the loop unitl it reaches the end position of the matrix
    {
        if (a[0][i]=='#'&&a[1][i]=='#'&&a[2][i]=='#')
          //checking the condition of gallexy
        {
            cout<<"#", i++;
        }
        else if (a[0][i]=='.'&&a[0][i+1]=='*'
        \&&a[0][i+2]=='.'&&a[1][i]=='*'&&a[1][i+1]=='*'
        \&&a[1][i+2]=='*'&&a[2][i]=='*'&&a[2][i+1]=='.'&&a[2][i+2]=='*')
        {
            //checking the condition of constellation shape A
            cout<<"A", i+=3;
        }
        else if (a[0][i]=='*'&&a[0][i+1]=='*'
        \&&a[0][i+2]=='*'&&a[1][i]=='*'&&a[1][i+1]=='*'
        \&&a[1][i+2]=='*'&&a[2][i]=='*'&&a[2][i+1]=='*'&&a[2][i+2]=='*')
        {
            //checking the condition of constellation shape E
            cout<<"E", i+=3;
        }
        else if (a[0][i]=='*'&&a[0][i+1]=='*'
        \&&a[0][i+2]=='*'&&a[1][i]=='.'&&a[1][i+1]=='*'
        \&&a[1][i+2]=='.'&&a[2][i]=='*'&&a[2][i+1]=='*'&&a[2][i+2]=='*')
        {
            //checking the condition of constellation shape I
            cout<<"I", i+=3;
        }
        else if (a[0][i]=='*'&&a[0][i+1]=='*'
        \&&a[0][i+2]=='*'&&a[1][i]=='*'&&a[1][i+1]=='.'
        \&&a[1][i+2]=='*'&&a[2][i]=='*'&&a[2][i+1]=='*'&&a[2][i+2]=='*')
        {
            //checking the condition of constellation shape O
            cout<<"O", i+=3;
        }
        else if (a[0][i]=='*'&&a[0][i+1]=='.'
        \&&a[0][i+2]=='*'&&a[1][i]=='*'&&a[1][i+1]=='.'
        \&&a[1][i+2]=='*'&&a[2][i]=='*'&&a[2][i+1]=='*'&&a[2][i+2]=='*')
        {
            //checking the condition of constellation shape U
            cout<<"U", i+=3;
        }
        else
        {
            // it is possible that random inputs are given in the character
            //array which might not form any such shape, here we do not
            //print anything we just increment the position of i and
            //check the next coloumn
            i++;
        }
    }
    return 0;
}