GROUP.PAS 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. CONST
  2. NScores = 5;
  3. NPupils = 8;
  4. type
  5. TScores = array [1..NScores] of 1..5;
  6. TPupil = record
  7. Name : string[30];
  8. Marks : TScores;
  9. Score : Word;
  10. end;
  11. var
  12. Pupils : array [1..NPupils] of TPupil;
  13. Temp : TPupil;
  14. Last : array [1..NPupils] of Byte;
  15. i,j : byte;
  16. begin
  17. Assign(Input,'2.txt');
  18. {$I-}
  19. Reset(Input);
  20. {$I+}
  21. If IOResult <> 0 then
  22. begin
  23. WriteLn('Error opening input file!');
  24. Halt(200);
  25. end;
  26. FillChar(Last,0,NPupils);
  27. for i := 1 to NPupils do
  28. with Pupils[i] do
  29. begin
  30. Read(Name);
  31. Score := 0;
  32. For j := 1 to NScores do
  33. begin
  34. Read(Marks[j]);
  35. Inc(Score,Marks[j]);
  36. if Marks[j] <= 2 then Inc(Last[i]);
  37. end;
  38. ReadLn;
  39. end;
  40. close(Input);
  41. for i := 1 to NPupils-1 do
  42. for j:= i+1 to NPupils do
  43. if Pupils[j].Score > Pupils[i].Score then
  44. begin
  45. Temp := Pupils[j];
  46. Pupils[j] := Pupils[i];
  47. Pupils[i] := Temp;
  48. end;
  49. Assign(Output,'Sorted.txt');
  50. Rewrite(output);
  51. WriteLn(' Результаты экзаменов ');
  52. WriteLn(' студенты отсортированы в порядке убывания успеваемости');
  53. for i := 1 to NPupils do
  54. begin
  55. Write(Pupils[i].Name);
  56. For j := 1 to NScores do
  57. Write(Pupils[i].Marks[j],' ');
  58. WriteLn;
  59. end;
  60. close(Output);
  61. Assign(OutPut,'exclude.txt');
  62. Rewrite(OutPut);
  63. WriteLn(' Список студентов, представленных на отчисление: ');
  64. for i := 1 to NPupils do
  65. if Last[i] > 1 then
  66. WriteLn(Pupils[i].Name);
  67. Close(OutPut);
  68. end.