Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- float mediaAlunos[4]; //variavel global por padrão estática
- int main(void) {
- float notas[4][4]; //variavel que armazena o tanto de alunos e os 4 bimestres
- int aluno, bimestre = 0;
- void calculo_media(float notas[][4], int posMatriz); //protótipo da função
- void ordem_crescente(float mediaAlunos[], int posVetor); //protótipo da função
- printf("-- SOFTWARE CALCULO DE NOTAS --\n"); //exibe mensagem
- for (aluno = 0; aluno < 4; aluno++) {
- for (bimestre = 0; bimestre < 4; bimestre++) {
- printf("Digite a nota do aluno %d: ", aluno+1); //pede pro usuario digitar algo
- scanf("%f", ¬as[aluno][bimestre]); //recebe a entrada do usuario
- if (notas[aluno][bimestre] > 10) { //verifica se a nota é maior que 10
- printf("Notas acima de 10 nao permitidas.\n");
- exit(0);
- }
- }
- }
- calculo_media(notas, 4); //inicia a função
- ordem_crescente(mediaAlunos, 4); //inicia a função
- system("pause");
- return(0);
- }
- void calculo_media (float notas[][4], int posMatriz) {
- int aluno, bimestre;
- //Calcula a media final do aluno
- for (aluno = 0; aluno < 4; aluno++) {
- printf("Calculando...\n");
- for (bimestre = 0; bimestre < 4; bimestre++) {
- mediaAlunos[aluno] = notas[aluno][bimestre] / 4;
- }
- }
- }
- void ordem_crescente (float mediaAlunos[], int posVetor) {
- int atual, prox, temporario;
- //Organinzando em ordem crescente
- for (atual = 0; atual < 4; atual++) {
- printf("-- ORGANIZANDO EM ORDEM CRESCENTE --\n");
- for (prox = atual + 1; prox < 4; prox++) {
- if (mediaAlunos[atual] > mediaAlunos[prox]) {
- temporario = mediaAlunos[prox];
- mediaAlunos[atual] = mediaAlunos[prox];
- mediaAlunos[prox] = temporario;
- }
- }
- }
- //Exibindo para o usuário
- for (atual = 0; atual < 4; atual++) {
- printf("Media %d: %.3f\n", atual+1, mediaAlunos[atual]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment