Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. type student = record
  2. name,surname:string;
  3. inf,phys,math:integer;
  4. end;
  5.  
  6. const N = 15;
  7.  
  8. var stud:student;
  9. i,j,k,menu,iii,ppp,mmm:integer;
  10. p:string;
  11. students: array [1..N] of student;
  12. found:boolean;
  13.  
  14. procedure readstudent(var stud:student);
  15. begin
  16. read(stud.name);
  17. read(stud.surname);
  18. read(stud.inf,stud.phys,stud.math);
  19. end;
  20.  
  21. procedure sortstudent(var stud1,stud2:student);
  22. var k:student;
  23. begin
  24. k:=stud1;
  25. stud1:=stud2;
  26. stud2:=k;
  27. end;
  28.  
  29. procedure writestudent(var stud:student);
  30. begin
  31. writeln(stud.name,' ',stud.surname,' ',stud.inf,' ',stud.phys,' ',stud.math);
  32. end;
  33.  
  34. begin
  35. found:=false;
  36. iii:=0; ppp:=0; mmm:=0;
  37. writeln('Выберите действие: ');
  38. writeln('1. Ввести массив студентов',#13,'2. Отсортировать по информатике',#13,'3. Отсортировать по имени',#13,'4. Отсортировать по среднему баллу',#13,'5. Вывести первого двоечника',#13,'6. Вывести последнего троечника',#13,'7. Вывести всех отличников',#13,'8. Вывести средние баллы по предметам',#13,'9. Выход');
  39. repeat
  40. read(menu);
  41. case menu of
  42. 1: for i:=1 to N do readstudent(students[i]);
  43. 2: begin
  44. for i:=1 to N-1 do
  45. for j:=1 to N-i do
  46. if students[j].inf > students[j+1].inf then sortstudent(students[j],students[j+1]);
  47. for i:=1 to N do
  48. writestudent(students[i]);
  49. end;
  50. 3: begin
  51. for i:=1 to N-1 do
  52. for j:=1 to N-i-1 do
  53. if students[j].surname > students[j+1].surname then sortstudent(students[j],students[j+1]);
  54. for i:=1 to N do writestudent(students[i]);
  55. end;
  56. 4:begin
  57. for i:=1 to N-1 do
  58. for j:=1 to N-i-1 do
  59. if (students[j].inf + students[j].phys + students[j].math)/3 > (students[j+1].inf + students[j+1].phys + students[j+1].math)/3 then sortstudent(students[j],students[j+1]);
  60. for i:=1 to N do writestudent(students[i]);
  61. end;
  62. 5: begin
  63. for i:=1 to N do
  64. if not (found) then
  65. if (students[i].inf = 2) or (students[i].phys = 2) or (students[i].math = 2) then begin
  66. writestudent(students[i]); found:=true;
  67. end;
  68. end;
  69. 6: begin
  70. for i:=N downto 1 do
  71. if not (found) then
  72. with students[i] do
  73. if (inf = 3) or (phys = 3) or (math = 3) then begin
  74. writestudent(students[i]); found:=true;
  75. end;
  76. end;
  77. 7: begin
  78. for i:=1 to N do
  79. with students[i] do
  80. if (inf = 5) and (phys = 5) and (math = 5) then writestudent(students[i]);
  81. end;
  82. 8: begin
  83. for i:=1 to N do begin
  84. iii:=iii+students[i].inf;
  85. ppp:=ppp+students[i].phys;
  86. mmm:=mmm+students[i].math;
  87. end;
  88. writeln(iii/N,#13,ppp/N,#13,mmm/N);
  89. end;
  90. end;
  91. until (menu = 9);
  92. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement