Subscribe Us

Responsive Advertisement

Advertisement

275A Lights Out codeforces solution in cpp

 

275A  Lights Out codeforces solution in cpp

by ujjal roy




#include<bits/stdc++.h>

using namespace std;

main()

{

    int i,m,j,c;

    int a[5][5]={{1,1,1,1,1},

                 {

                     1,1,1,1,1

                 },

                 {

                     1,1,1,1,1

                 },

                {

                     1,1,1,1,1

                 },

                {

                     1,1,1,1,1

                 },


                   };


    for(i=1;i<=3;i++)

    {

        for(j=1;j<=3;j++)

        {

            cin>>m;

              if(m%2==1)

            {

                if(a[i][j]==0) a[i][j]=1;

                else a[i][j]=0;


                if(a[i+1][j]==0) a[i+1][j]=1;

                else a[i+1][j]=0;


                if(a[i][j+1]==0) a[i][j+1]=1;

                else a[i][j+1]=0;

                 if(a[i][j-1]==0) a[i][j-1]=1;

                else a[i][j-1]=0;

                if(a[i-1][j]==0) a[i-1][j]=1;

                else a[i-1][j]=0;



            }

        }

    }


    for(i=1;i<=3;i++)

    {

        for(j=1;j<=3;j++)

        {

           cout<<a[i][j];


        }

        cout<<endl;

    }



    return 0;

}


Post a Comment

0 Comments