// use less

#include"c:\tc\bin\marathan\a.cpp"

int arr[181];

void check_row(int no)
{
 int other;
 if (no==1)
  other=2;
 else
  other=1;

 int i,ii;
 int start,end;
 fillcolor color;

 for(i=0;i<181;i++)//check row wise
 {
  if(arr[i]==no&&arr[i+1]==other)//if other traped by no
  {
   start=i+1;
   do
   {
    i=i+1;
   }while(arr[i]==other);
   end=i;
   if(arr[i]==no)
   {
    if(return_row(start)==return_row(end))
    {
      /////////////U got the position
     for(ii=start;ii<=end;ii++)
     {
      arr[ii]=no;
      if(no==1)
       color=yellow;
      else
       color=white;
      draw_circle(calc_rev_pos(i),color);
     }
    }
   }
  }
 }
}



void check_column(int no)
{

}

void main()
{
 initialize();
 draw_all();

 for(int i=0;i<181;i++)
  arr[i]=0;

 int row,col;
 row=1;
 col=7;
 fillcolor cc;

 settextstyle(1,0,1);
 do
 {
   //////////PLAYER       1
  setcolor(getbkcolor());
  outtextxy(480,400,"PLAYER 2");
  cc = yellow;
  setcolor(cc);
  outtextxy(480,400,"PLAYER 1");

  int aa;
  do
  {
   aa=move(row,col);
   row=aa/19;
   col=aa%19;
  }while(arr[calc_pos(aa)]!=0);

  draw_circle(aa,cc);
  arr[calc_pos(aa)]=1;
  check_column(1);
  check_column(2);

  //////////PLAYER       2
  setcolor(getbkcolor());
  outtextxy(480,400,"PLAYER 1");
  cc = white;
  setcolor(cc);
  outtextxy(480,400,"PLAYER 2");
  do
  {
   aa=move(row,col);
   row=aa/19;
   col=aa%19;
  }
  while(arr[calc_pos(aa)]!=0);

  draw_circle(aa,cc);
  arr[calc_pos(aa)]=2;
  check_column(2);
  check_column(1);

 }while(1);

// getch();
// closegraph();
}




/*

 int i,j,ii;
 int other;
 if (no==1)
  other=2;
 else
  other=1;

 int i1,i2;
 int start,end;
 fillcolor color;

 for(j=0;j<2;j++)
 {
  if(j==0)
  {
   i1=37;
   i2=132;
  }
  else
  {
   i1=49;
   i2=144;
  }
  for(i=i1;i<i2;i++)
  {
   if(arr[i]==no&&arr[i+18]==other)//if other traped by no
   {
    start=i+18;
    do
    {
     i=i+18;
    }while(arr[i]==other&&i<i2+1);
    end=i;
    if(arr[i]==no&&i<i2+1)
    {
     for(ii=start;ii<=end;ii=ii+18)
     {
      arr[ii]=no;
      if(no==1)
       color=yellow;
      else
       color=white;
      draw_circle(calc_rev_pos(ii),color);
     }
    }
   }
  }
 }

 int arrtemp[7][19];
 for(i=1;i<7;i++)
  for(j=1;j<7;j++)
   arrtemp[i][j]=arr[(i-1)*6+j];
 for(i=1;i<7;i++)
  for(j=7;j<13;j++)
   arrtemp[i][j]=arr[(i-1)*18+j+42];
 for(i=1;i<7;i++)
  for(j=13                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           