1
hello I made a program in order to multiply each element of each row of an array by its highest value element, but my program multiplies each one by itself
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
//achar maior menor de cada linha da matriz e e multiplicar cada numero da linha por ele
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] || mat[i][j]==mat[i][j] )//se o elemento na posição mat={i,j} for o maior numero da linha
{
aux=mat[i][j];//guardar em aux
mat[i][j]=mat[i][j]*aux;
}
}
}
system("cls");
fflush(stdin);
for(i=0; i<=3; i++)
{
for(j=0; j<=3; j++)
{
printf("[%d]", mat[i][j]);
}
printf("\n");
}
return 0;
}
Hello Leonardo, I read some of your previous questions and I had the impression that you are trying to solve a series of exercises with C in Windows environment (correct me if I’m wrong). I would just like to leave a comment: Have you figured out how to use the GDB? The Debugger can help you a lot. What’s more, most IDES (including Dev-C++ that college teachers like to recommend) support GDB.
– Anthony Accioly
yes windows use, thanks @Anthonyaccioly I to in 2 period of computer science I get the questions here why staff respond and faculty teachers will not look for GDB
– Leonardo V. De Gasperin