Ir para o conteúdo

PassingGrade

Desafio

Resolução em C

#include <stdio.h>

int main()
{
    double notas = 4;
    double points_earned[4] = {55, 77, 82, 60};
    double points_possible[4] = {100, 100, 100, 100};
    double final_exame = 300;
    int i; 
    double j, percent = 0, math;

    for(i=0; i <= notas; i++) {
        percent += points_earned[i] / points_possible[i];   
    }

    for(j=0; j <= final_exame; j++) {
        if(j == 0) math = percent / (notas + 1);
        else math = ((j / final_exame) + percent) / (notas + 1);

        if((math * 100) < (float)65) continue;
        if((math * 100) >= (float)65) {
            printf("Nota minima exame: %d", (int)j);
            break;
        }
    }

    return 0;
}