Pascal. Файлы. Задача 5

Создать тест из 5 вопросов на тему ЯП Pascal. Вопросы должны выводиться на экран из файла по одному. В конце тестирующий получает количество вопросов, на которые он ответил правильно.

Решение:

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
program file_5;
uses crt;
var
i, k: integer;
s, x: string;
t_file, o_file: text;
begin
clrscr;
assign(t_file, ‘test.txt’);
assign(o_file, ‘otvet.txt’);
reset(t_file); reset(o_file);
k:=0;
while not eof(t_file) do
begin
for i:=1 to 6 do
begin
readln(t_file, s);
writeln(s);
end;
readln(o_file, s);
write(‘Ответ > ‘); read(x);
if x=s then k:=k+1;
clrscr;
end;
write(‘правильных ответов: ‘, k);
close(t_file); close(o_file);
readkey;
end.
Рейтинг
( Пока оценок нет )
Загрузка ...