Advertisement
Herowaree

Pascal - Exame Final

Nov 19th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. //fpc 3.0.0
  2.  
  3. program HelloWorld;
  4.  
  5. Uses sysutils;
  6.  
  7. const
  8. numero_alternativas = 5;
  9. numero_questoes = 10;
  10. nota_minima = 6;
  11. var
  12. resp_alunos: array of array of integer;
  13. nome_alunos: array of String;
  14. notas_alunos: array of integer;
  15. gabarito: array of integer;
  16. i, j: integer;
  17. numero_alunos: integer;
  18. begin
  19.  
  20. //Ler o número de alunos
  21. numero_alunos := 10;
  22.  
  23. //Definir tamanho dos arrays
  24. SetLength(resp_alunos, numero_alunos, numero_questoes);
  25. SetLength(nome_alunos, numero_alunos);
  26. SetLength(notas_alunos, numero_alunos);
  27. SetLength(gabarito, numero_questoes);
  28.  
  29. //Ler a respostas das questões
  30. writeln('GABARITO >>>');
  31. for i:= 0 to numero_questoes - 1 do begin
  32. gabarito[i] := Random(numero_alternativas) + 1;
  33. writeln('Resposta da questão '+ IntToStr(i + 1) +': '+ IntToStr(gabarito[i]));
  34. end;
  35.  
  36. //Ler o nome dos alunos e a resposta das questões
  37. writeln('NOME DOS ALUNOS E RESPOSTAS >>>>');
  38. for i:= 0 to numero_alunos - 1 do begin
  39. nome_alunos[i] := 'aluno_' + IntToStr(i + 1);
  40. notas_alunos[i] := 0;
  41. writeln('Nome do aluno: '+ nome_alunos[i]);
  42. for j:= 0 to numero_alunos - 1 do begin
  43. resp_alunos[i, j] := Random(numero_alternativas) + 1;
  44. writeln('Resposta da pergunta '+ IntToStr(j + 1) + ': '+ IntToStr(resp_alunos[i,j]));
  45. end;
  46. end;
  47.  
  48. //Comparar respostas com o gabarito
  49. for i := 0 to numero_alunos - 1 do begin
  50. for j := 0 to numero_questoes - 1 do begin
  51. if(resp_alunos[i, j] = gabarito[j]) then begin
  52. notas_alunos[i] := notas_alunos[i] + 1;
  53. end;
  54. end;
  55. //writeln('O aluno '+ nome_alunos[i] +' obteve a nota ' + IntToStr(notas_alunos[i]));
  56. end;
  57.  
  58. //Imprimir os alunos com nota maior ou igual que a minima
  59. writeln('ALUNOS APROVADOS >>>>');
  60. for i:=0 to numero_alunos - 1 do begin
  61. if(notas_alunos[i] >= nota_minima) then begin
  62. writeln('O aluno '+ nome_alunos[i] +' obteve a nota ' + IntToStr(notas_alunos[i]));
  63. end;
  64. end;
  65.  
  66. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement