-
Notifications
You must be signed in to change notification settings - Fork 0
/
shablon.lpr
183 lines (150 loc) · 3.94 KB
/
shablon.lpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
program shablon;
{$mode objfpc}{$H+}{$R+}
uses {$IFDEF UNIX} {$IFDEF UseCThreads}
cthreads, {$ENDIF} {$ENDIF}
Classes,
Windows,
// Crt, test_form { you can add units after this };
Crt;
var
answer, number, q, a, b, c, t, g, i, j, o, p, r, k, answer2, question,
vse, right: integer;
h, percent: real;
flag: boolean;
mas: array [1..5] of integer;
questions: array [1..17, 1..2] of string;
f_in: Text;
S: string;
// myForm: test_form;
label
1, 4, 5, 6;
{à®æ¥¤ãà ¨¨æ¨ «¨§ 樨 ¬ ᨢ ¢®¯à®á®¢}
procedure InitQuestions();
begin
Assign(f_in, 'questions.txt');
reset(f_in);
for i := 1 to 17 do // ª®«-¢® ¢®¯à®á®¢
begin
for j := 1 to 2 do
begin
readln(f_in, questions[i, j]);
end;
end;
Close(f_in);
end;
{”ãªæ¨ï ªà ᨢ®£® ä®à¬ â¨à®¢ ¨ï ¢®¯à®á®¢}
function FormatQuestion(anQuestion: string): string;
begin
Result := copy(anQuestion + ' ', 1, 10);
end;
procedure PrintAllQuestions;
begin
for i := 1 to 17 do
begin
Write(i, ')');
writeln(FormatQuestion(questions[i, 1]), ' - ', questions[i, 2]);
end;
end;
{Žá®¢ ï ¯à®£à ¬¬ }
begin
writeln('Ïðèâåò!');
writeln('‡¤¥áì ï ¨ Œ ªá ¯®¯à®¡ã¥¬ ¯®¬®çì ¢ ¬ á ¯®¨¬ ¨¥¬ Pascal ,¥á«¨ ¢ë 諨 ª ªãî-¨¡ã¤ì ®è¨¡ªã ®¡à é ©â¥áì ª ¬ )))');
Write('‘¥©ç á ¢ë¡¥à¨â¥ â®,çâ® ¢ë å®â¥«¨ ¡ë 㧠âì');
writeln('(‚® ¢á¥© ¯à®£à ¬¬¥ ¢ ¬ 㦮 ¢ë¡¨à âì ⮫쪮 æ¨äàë) ');
c := 1;
flag := False;
while c = 1 do
begin
InitQuestions();
flag := True;
writeln('');
writeln('');
writeln('1)®¯¥à â®àë 2)¯à®¢¥àª ¢ëãç¥ëå ®¯¥à â®à®¢ 3)¥è¥¨¥ § ¤ ç 4)‚ë室');
Read(q);
clrscr; // Š®¬ ¤ ®ç¨á⪨ íªà
writeln('');
if q = 4 then
exit;
if q = 1 then
begin
PrintAllQuestions;
end;
if q = 2 then
begin
writeln(
'…᫨ ¢ë å®â¨â¥ ¢ë©â¨ ¨§ à §¤¥« ,¢ ¬ 㦮 ¢¢¥á⨠¢¬¥áâ® ®â¢¥â ç¨á«® 12345.');
writeln('');
writeln('—â® ®¡®§ ç ¥â ¤ ë© ®¯¥à â®à:');
percent := 0;
while (percent < 70) or (vse < 10) do
begin
if vse > 50 then
begin
writeln('‚ ¬ 㦮 ¥éñ ¯®¢â®à¨âì ¯®ïâ¨ï .');
break;
end;
//‚ë¡¨à ¥¬ ¢®¯à®á
randomize;
question := random(17) + 1;
// writeln('—â® ®¡®§ ç ¥â ¤ ë© ®¯¥à â®à:');
writeln('');
writeln(questions[question, 1]);
writeln('');
p := 1;
answer := question;
while p <> 5 do
//§ ¯¨áë¢ î æ¨äàë ¢ ¬ áᨢ ,¤«ï ⮣® çâ®¡ë ¯®â®®¬ ¨å ¯¥à¥âãᮢ âì
begin
mas[p] := random(17) + 1;
for j := 1 to p - 1 do
begin
if (mas[p] = mas[j]) or (mas[p] = answer) then
begin
p := p - 1;
break;
end;
end;
p := p + 1;
end;
number := random(5) + 1;
mas[5] := mas[number];
mas[number] := answer;
for i := 1 to 5 do
begin
Write(i, ')');
writeln(questions[mas[i], 2]);
end;
writeln('');
Write('‚ è ¢ë¡®à: ');
readln(answer2);
if answer2 = 12345 then
break;
if answer2 = number then
begin
right := right + 1;
writeln('‚ë ®â¢¥â¨«¨ ¯à ¢¨«ì®.');
end
else
writeln('‚ë ®â¢¥â¨«¨ ¥ ¯à ¢¨«ì® ,¯à ¢¨«ìë© ®â¢¥â:', number, ')');
vse := vse + 1;
if right <> 0 then
percent := right / vse * 100
else
percent := 0;
Str(percent: 6: 1, S);
writeln('à®æ¥â ¯à ¢¨«ìëå ®â¢¥â®¢: ', S, '%');
writeln(
'‚¢¥¤¨â¥ «î¡®¥ ç¨á«® ,¤«ï ¯®ª § á«¥¤ãî饣® ®¯¥à â®à .');
Read(h);
clrscr;
writeln('‘«¥¤ãî騩 ®¯¥à â®à: ');
end;
writeln(
'‚ë § ¥â¥ ¤®áâ â®ç® ¤«ï ⮣®, çâ®¡ë ¯¥à¥©â¨ ª á«¥¤ãî饬ã à §¤¥«ã.');
end;
if q = 3 then
begin
writeln('®ª ¨ç¥£®');
end;
end;
end.