Runtime error for a simple scenario
hi ...
my i/p canbe of format.
Quote:
$ $ $ . . $
$ . $ . . $
here the number of rows and cols is 2 and 5.
i have to consider whenevr the dots come into play.
as i encou nter each dot i increment a counter meaning that is 1st dot,2nd dot and so on...
in the first row i have two dots... so i name them as 1 and 2...
whenever 2 dots are adjacent or one below the other i need to associate those dots...
here in the i/p above i have to associate
1 2
1 4
and 2 5
this seems to be simple...but am getting runtime error for the following processing... can anyone help me plzz....
Code:
#include<iostream>
#include<string.h>
#define max 100
using namespace std;
int main()
{
long long int t,i,j,count=0,a[max][max],m,n;
char c[max][max];
cin>>m>>n;
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%c",&c[i][j]);
if((c[i][j]=='.')&&(count==0))
{
count++;
a[i][j]=count;
goto s10;
}
if((c[i][j]=='.')&&(count!=0))
{
count++;
a[i][j]=count;
if(i!=0)
if(c[i-1][j]=='.') cout<<"\n"<<a[i-1][j]<<"and"<<a[i][j];
if(j!=0)
if(c[i][j-1]=='.') cout<<"\n"<<a[i][j-1]<<"and"<<a[i][j];
}
s10:
;
}
}
return 0;
}