TOPIC

Onde está o erro?

Andre Machado do Monte asked 1 year ago

include

int main(int argc, char *argv[]) { int N = 0;

printf("Please digite a quantidade de linhas que vc quer: ");
scanf("%d", &N);

float cnt[100][100];
float result[100];

for(int l = 0; l < N; l++) {
    for(int c = 0; c < 3; c++) {
        scanf("%f", &cnt[l][c]);
    }
}

for(int l = 0; l < N; l++) {
    for(int c = 0; c < 3; c++) {

        //peso 0.2
        if(c == 0) {
            result[l] += cnt[l][c] * 0.2;
        }

        //peso 0.3
        if(c == 1) {
            result[l] += cnt[l][c] * 0.3;
        }

        //peso 0.5
        if(c == 2) {
            result[l] += cnt[l][c] * 0.5;               
        }
    }
}
for(int g = 0; g < N; g++) {
    printf("average is: %.1f\n", result[g]);    
}

}

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.