Turma, boa tarde!
Quem puder me ajudar eu agradeço muito
esse é o trabalho e eu comecei com o codigo fazendo as celulas vizinhas assumirem valor dois, mas aparentemente nao esta dando certo… Alguem me salva nesse trabalho por favor!!!
#include <stdio.h>
int escreve( int n[5][5] );
int main()
{
int j = 0;
int i = 0;
int n [5][5] =
{
0 , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 2 , 0 , /// 2 = preta
0 , 0 , 0 , 0 , 0 , /// 0 = branco
0 , 0 , 0 , 0 , 0 , /// 1 = cinza
0 , 0 , 0 , 0 , 0//
};
escreve( n );
for( i=0; i<5; i++ )
{
for ( j=0; j<5; j++ )
{
if( n[i][j] == 2 )
{
n[i ][j] = 1;
if(i>0) n[i-1][j] = 2;
if(i<5) n[i+1][j] = 2;
if(j>0) n[i][j-1] = 2;
if(j<5) n[i][j+1] = 2;
i = 5;
break;
}
}
}
escreve( n );
return 0;
}
int escreve( int n[5][5] )
{
int j,i;
printf("\n");
for( i=0; i<5; i++ )
{
for ( j=0; j<5; j++ )
{
printf("%3d" , n[i][j] );
}
printf("\n");
}
}