I have a problem with this program, I need in an array [4] [4] to find the maximum of each line and multiply by each line number, in my program it has a syntax error, because I keep the largest number and it only multiplies by the last number of each line for example:
mat[i][j]={0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15}
would be:
mat[i][j]={0, 1, 2, 9,
4, 5, 6, 49,
8, 9, 10, 121,
12, 13, 14, 225}
My code:
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
//achar maior menor de cada linha da matriz
int main(int argc, char *argv[])
{
int mat[4][4];
int i, j, aux;
//le matriz
for(i=0; i<=3; i++)
{
for(j=0; j<=3; j++)
{
setlocale(LC_ALL, "Portuguese");
printf("digite um numero para a posição %d e coluna %d de mat:\n", i, j);
scanf("%d", &mat[i][j]);
}
}
//1ºfase de processamento
for(i=0; i<=3; i++)
{
for(j=0; j<=3; j++)
{
if(mat[i][j]>=mat[i][j])//se o elemento na posição mat={i,j}
//for maior que o ultimo elemento da linha
{
aux=mat[i][j];//guardar em aux
mat[i][j]=mat[i][j]*aux;
}
}
}
If someone knows what I did wrong, I would like some explanation I'm having a lot of syntax problem.