Created
July 17, 2014 02:37
-
-
Save gabrielbiga/53939d36a86cf6cb3ba8 to your computer and use it in GitHub Desktop.
Corrigindo Múltipla Escolha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
//Offset de Q | |
#define Q 100 | |
int main() { | |
int i, j; //laços | |
int quantidadeAlternativas; //Quantidade total de alternativas corretas | |
int quantidadeAlunos; | |
int inscrito; | |
int alternativasCorretas; | |
char gabarito[Q]; | |
char gabaritoAluno[Q]; | |
//Pegando quantidade de alternativas | |
scanf("%d", &quantidadeAlternativas); | |
//Se quiser tratar a quantidade maior do que os limites dados... | |
/*if (quantidadeAlternativas <= 5 || quantidadeAlternativas >=100) { | |
return; | |
}*/ | |
//Lotando o array gabarito | |
for (i = 0, fflush(stdin); i < quantidadeAlternativas; scanf("%c", &gabarito[i]), i++); | |
fflush(stdin); | |
//Pegando quantidade | |
scanf("%d", &quantidadeAlunos); | |
for (i = 0; i < quantidadeAlunos; i++) { | |
fflush(stdin); | |
alternativasCorretas = 0; | |
scanf("%d", &inscrito); | |
for (j = 0; j < quantidadeAlternativas; scanf(" %c", &gabaritoAluno[j]), j++); | |
//Fazendo comparacao... | |
for (j = 0; j < quantidadeAlternativas; j++) { | |
//Como eh char, soh fazer a cmp assim | |
if (gabaritoAluno[j] == gabarito[j]) { | |
alternativasCorretas++; | |
} | |
} | |
//Mostrando no final | |
printf("%d %d\n", inscrito, alternativasCorretas); | |
} | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment