1
I’m wondering how to create a function where you will use the values of an int main matrix, and then how to replace the values obtained in the function matrix for the int main matrix?
I was creating the function so:
int JogadaComp2 (int tabuleiro[3][3])
{
if ( tabuleiro [2][2] = 0) { tabuleiro[2][2] = 1;return 0;}
if ( tabuleiro [1][1] == 2 && tabuleiro [1][2] == 2 && tabuleiro [1][3] ==
0) { tabuleiro[1][3] = 1;return 0;}
if ( tabuleiro [1][1] == 2 && tabuleiro [2][1] == 2 && tabuleiro [3][1] ==
0) { tabuleiro[3][1] = 1;return 0;}
return tabuleiro[3][3];
}
and to replace the values in the int main matrix:
int main (){
int tabuleiro[3][3];
tabuleiro[3][3] = JogadaComp2(tabuleiro[3][3]);
for(l=0;l<3;l++)
{
for(c=0;c<3;c++)
{
printf("%d", tabuleiro[l][c];
}
printf("\n";
}
return 0;
}
The spelling mistakes are due to me summarizing the code to clear my doubts, I just summed up the part I wasn’t able to do. But anyway thanks for the reply.
– Renan Mela
@Renanmela Of nothing. Did well to summarize, the goal is always to have the minimum necessary only for the problem in question. I chose to point out anyway because I was in doubt whether I really had the mistakes or not, and if I did, I also knew what to fix.
– Isac