Im trying to solve a ACM problem 10189,
It looks ok to me...but, online judge is showing wrong answer...
can anyone help me to figure out the problem.
#include<stdio.h>
int row = 1, column = 1,i=0, j=0, a=0, b=0;
char array[100][100] = {0};
int change(int a, int b)
{
if(!(a < 0) && !(a > row -1) && !(b<0) && !(b > column -1))
if(!(array[a][b] == '*'))
if(array[a][b] == '.')
array[a][b] = 49;
else
++array[a][b];
return 0;
}
int main()
{
freopen("in.txt", "r", stdin);
int count = 0;
while(!(row == 0 && column == 0))
{
scanf("%d %d", &row, &column);
if(row == 0 && column == 0) return 0;
count++;
for(i=0; i<row; i++)
{
scanf("\n");
for(j=0; j<column; j++)
{
scanf("%c", &array[i][j]);
}
}
for(i=0; i<row; i++)
{
for(j=0; j< column; j++)
{
if(array[i][j] == '*')
{
a = i-1;
b = j-1;
change(a, b);
a = i-1;
b = j;
change(a, b);
a = i-1;
b = j+1;
change(a, b);
a = i;
b = j+1;
change(a, b);
a = i+1;
b = j+1;
change(a, b);
a = i+1;
b = j;
change(a, b);
a = i+1;
b = j-1;
change(a, b);
a = i;
b = j-1;
change(a, b);
}
}
}
printf("Field #%d:", count);
for(i=0; i<row; i++)
{
printf("\n");
for(j=0; j< column; j++)
{
if(array[i][j] == '.') array[i][j] = 48;
printf("%c",array[i][j]);
}
}
printf("\n\n");
}
return 0;
}
Though, i have a little confusion about the double "new line"(\n) at the end of the program...i have managed to get ride of it.But it is still showing Wrong Answer. :(