• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Dec 3rd, 2019 90 in 168 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. uses
2.   Math,
3.   SysUtils;
4.
5.
6. type
7.   tStudent = record
8.     surname: string[20];
9.     mark: integer;
10.   end;
11.
12. type
13.   tarr = array of tStudent;
14.
15.   procedure MyInput(var c: tarr; var n: integer);
16.   var
17.     i: integer;
18.     buf: string;
19.   begin
20.     i := 0;
22.     while (buf <> '*') do
23.     begin
24.       n := i + 1;
25.       SetLength(c, n);
26.       c[i].surname := copy(buf, 1, pos(' ', buf)-1);
27.       //writeln(' ', c[i].surname);
28.       delete(buf, 1, pos(' ', buf));
30.       c[i].mark := StrToInt(buf) ;
32.       i := i + 1;
33.     end;
34.   end;
35.
36.   function average(c: tarr; n: integer): double;
37.   var
38.     i: integer;
39.     sum: integer;
40.   begin
41.     sum := 0;
42.     for i := 0 to n - 1 do
43.       sum := sum + (c[i].mark);
44.     Result := sum / n;
45.     writeln();
46.     writeln('Average = ', Result:4:2);
47.   end;
48.
49.   procedure selection(var c: tarr; n: integer; q: double);
50.   var
51.     i: integer;
52.   begin
53.     writeln();
54.     writeln('Got marks not lower than average:');
55.     for i := 0 to n - 1 do
56.       if c[i].mark >= q then
57.         writeln(c[i].surname);
58.   end;
59.
60.   {задача 4}
61.   procedure deletion(var c: tarr; var n: integer);
62.   var
63.     i, j: integer;
64.   begin
65.     i := 0;
66.     while i < n do
67.     begin
68.       if c[i].mark = 5 then
69.       begin
70.         for j := i to n-2 do
71.           c[j] := c[j+1];
72.         n := n - 1;
73.       end
74.       else
75.         i := i + 1;
76.     end;
77.     SetLength(c, n);
78.   end;
79.
80.   procedure MyOutput(c: tarr; n: integer);
81.   var
82.     i: integer;
83.   begin
84.     for i := 0 to n - 1 do
85.     begin
86.       writeln(c[i].surname, ' ', c[i].mark);
87.     end;
88.   end;
89.
90. var
91.   w: tarr;
92.   n: integer;
93.   k: double;
94.
95. begin
96.   n := 0;
97.   writeln('Enter surname and mark, put *, when you finish');
98.   MyInput(w, n);
99.   k := average(w, n);
100.   selection(w, n, k);
101.   deletion(w, n);
102.   writeln();
103.   writeln('Got marks lower than 5:');
104.   MyOutput(w, n);