0
I need to find the lowest value of each matrix row. The values appear missing or the most (much more).
What I have so far:
#include <stdio.h>
#include <stdlib.h>
int main()
{
float notas[][3] = {0};
float menor = 0.0;
//preenchendo matriz
for(int aluno = 0; aluno < 10; aluno++)
{
for(int prova = 0; prova < 3; prova++)
{
notas[aluno][prova] = rand() % 10;
}
}
//Exibindo as notas
printf("\t COL 0 COL 1 COL 2\n");
for(int aluno = 0; aluno < 10; aluno++)
{
printf("LINHA %d - ", aluno);
for(int prova = 0; prova < 3; prova++)
{
printf("%.2f ", notas[aluno][prova]);
}
printf("\n");
}
int Pior = 0;
int Vpior[3] = {0};
for(int aluno = 0; aluno < 10; aluno++)
{
Pior = 0;
menor = notas[0][0];
for(int prova = 0; prova < 3; prova++)
{
if(notas[aluno][prova]<menor)//
{
menor = notas[aluno][prova];
Pior++;
}
}
Vpior[aluno] = Pior;
}
printf("\n");
for(int r = 0; r < 3; r++){
printf("Piores na:\nProva %d = %d\n",
r+1, Vpior[r]);
}
return 0;
}
Your grade statement is wrong, use:
float notas[10][3] = {0};
. Note that to usenotas[aluno][prova] = rand() % 10;
no one can take a 10, the notes will vary between 0 and 9. Here:menor = notas[0][0];
should bemenor = notas[aluno][0];
. First you have to determine the worst grade and then sweep all students to count those who took this grade (you are counting how many times you changed the worst grade). Be careful to count the worst grade of a student only once.– anonimo
I made the modification you said, but the result was the same as before, still, thanks for the help.
– Rafael S.