/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <stdlib.h>
#include <ctime>
using namespace std;
int nl,nc,i,j,l,c,a[100][100],cucu,r;
void umplu(int l,int c)
{
a[l][c]=1;
if ((l>1)&&(a[l-1][c]==0)) umplu(l-1,c);
if ((c>1)&&(a[l][c-1]==0)) umplu(l,c-1);
if ((c<nc)&&(a[l][c+1]==0)) umplu(l,c+1);
if ((l<nl)&&(a[l+1][c]==0)) umplu(l+1,c);
}
int main()
{
r=1;
//clrscr();
cout<<"linii=";cin>>nl;
cout<<"coloane=";cin>>nc;
cout<<endl;
srand(time(0));
for (i=1;i<=nl;i++)
for (j=1;j<=nc;j++){
cucu=(rand()%2);
a[i][j]= cucu;
}
//clrscr();
cout<<" ";
for (j=1;j<=nc;j++) cout<<j%10;cout<<endl;
for (i=1;i<=nl;i++) {
cout<<i%10<<" ";
for (j=1;j<=nc;j++) if(a[i][j])cout<<'*';
else cout<<" ";
cout<<endl;
}
cout<<endl;
while (r==1) {
cout<<"linia=";cin>>l;
cout<<"coloana=";cin>>c;
cout<<endl;
umplu(l,c);
//clrscr();
cout<<" ";
for (j=1;j<=nc;j++) cout<<j%10;
cout<<endl;
for (i=1;i<=nl;i++) {
cout<<i%10<<" ";
for (j=1;j<=nc;j++) if(a[i][j])cout<<'*';
else cout<<" ";
cout<<endl;
}
cout<<endl;
cout<<"continuati?";cin>>r;
cout<<endl;
}
return 0;
}