WWW.ИСХОДНИКИ.РУ cpp.sources.ru
java.sources.ru web.sources.ru soft.sources.ru
jdbc.sources.ru asp.sources.ru api.sources.ru

  Форум на исходниках
  Pascal
  Тестовая программа

СПРОСИТЬ  ОТВЕТИТЬ
профайл | регистрация | faq

Автор Тема:   Тестовая программа
AlexR опубликован 09-02-2002 13:32 MSK   Click Here to See the Profile for AlexR   Click Here to Email AlexR  
Дайте, пожайлуста исходники тестовой программы на Паскале.
Valery Votintsev опубликован 09-02-2002 13:52 MSK     Click Here to See the Profile for Valery Votintsev  Click Here to Email Valery Votintsev     
program TestProg;
begin
writeln('Тестовая программа на Паскале.');
end.

;-D

ozzy опубликован 09-02-2002 15:51 MSK     Click Here to See the Profile for ozzy  Click Here to Email ozzy     
В смысле исходники программы, которая реализует тесты?
Типа таких:
Не Париж ли столица Франции?
1. Да
2. Нет
3. Затрудняюсь ответить
Есть что-такое на bp7+tv
AlexR опубликован 09-02-2002 19:04 MSK     Click Here to See the Profile for AlexR  Click Here to Email AlexR     
to ozzy: вот, именно это!
NOPIK опубликован 11-02-2002 01:46 MSK     Click Here to See the Profile for NOPIK  Click Here to Email NOPIK     
а таких есть в SWAGе...
А если сюды бухнуть... Хе-хе...

Program Test(input,output);
Type
StringsList=record {Strings with questions and answers}
s:string;
p,n:pointer;{list element pointers}
end;
pStringsList=^StringsList;
Answer=record{Answers list}
points:integer;
as:pStringsList;
p,n:pointer;
end;
pAnswer=^Answer;
Form=record
q:pStringsList;
a:pAnswer;
timeout:integer;{well... it must be, but Pascal have not standard time functions}
n,p:pointer;
end;
pForm=^Form;
Var
rs:string;{operation string}
f:Text;{file}
l:pForm;{Forms list pointer}
p:pointer;{operation pointer}
errorstate:integer;{runtime error flag}
PointsSum:longint;{gained points}
TotalPoints:longint;{points to pass the test}
res:integer;{any results}
Procedure Error(reason:string);
begin
Writeln('Error: ',reason);
Errorstate:=length(reason);{can be used to analyse reason}
end;
procedure ShowQuestion(qn:pForm);
var
pt:pStringsList;
pa:pAnswer;
num:Integer;{question number}
a:Integer;{answer number}
begin
if qn=nil then Error('Can''t ask nil question!')
else
begin
num:=0;
pt:=qn^.q;
while pt^.p<>nil do pt:=pt^.p;{set pointer to first string in list}
while pt<>nil do
begin
WriteLn(pt^.s);{Question string}
pt:=pt^.n;{next string, if present}
end;
pa:=qn^.a;
while pa^.p<>nil do pa:=pa^.p;{set pointer to first answer in list}
while pa<>nil do
begin
Num:=Num+1;
Write(Num,'. ');{Question number}
pt:=pa^.as;
while pt^.p<>nil do pt:=pt^.p;{set pointer to first string in list}
while pt<>nil do
begin
WriteLn(pt^.s);{Answer string}
pt:=pt^.n;{next string, if present}
end;
pa:=pa^.n;{next question}
end;
Repeat
Write('Type answer number and press Enter');
ReadLn(a);
Until (a>0) and (a<=Num);{only possible numbers}
pa:=qn^.a;
while pa^.p<>nil do pa:=pa^.p;{set pointer to first answer in list}
Num:=1;
While Num<>a do
begin
pa:=pa^.n;{set pointer to answer to check it}
Num:=Num+1;
end;
PointsSum:=PointsSum+pa^.points;{adding points}
if pa^.points=0 then WriteLn('Wrong answer')
else WriteLn('You gained ',PointsSum,' points');
end;
end;{Show question}
begin{Main procedure}
res:=0;
errorstate:=0;
pointsSum:=0;
TotalPoints:=0;
l:=nil;{No questions, no answers...}
p:=nil;{operating pointer}
Assign(f,'test.txt');
Reset(f);
while (not eof(f)) and (ErrorState=0) do
begin
Readln(f,rs);
if Length(rs)>2 then
begin
if Pos('Q?',rs)=1 then
begin
if l<>nil then ShowQuestion(l);{Show already parsed question}
p:=New(pForm);
if p=nil then Error('No memory for form!')
else
begin
if l<>nil then l^.n:=p;
pForm(p)^.p:=l;
l:=p;{New form in list}
l^.timeout:=0;{not implemented}
p:=New(pStringsList);{NewQuestion}
if p=nil then Error('No memory for question!')
else
begin
l^.q:=p;
pStringsList(p)^.p:=nil;
pStringsList(p)^.n:=nil;
pStringsList(p)^.s:=Copy(rs,3,Length(rs)-2);{cutting header}
end;
l^.a:=nil;{answers will be later}
end;
end{of question header}
else
if Pos('A?',rs)=1 then
begin
p:=New(pAnswer);
if p=nil then Error('No memory for answers!')
else
begin
pAnswer(p)^.n:=nil;
pAnswer(p)^.p:=l^.a;
if l^.a<>nil then l^.a^.n:=p;
l^.a:=p;{set questions pointer to new}
p:=New(pStringsList);{NewQuestion}
if p=nil then Error('No memory for question!')
else
begin
l^.a^.as:=p;
pStringsList(p)^.p:=nil;
pStringsList(p)^.n:=nil;
pStringsList(p)^.s:=Copy(rs,Pos(')',rs)+1,Length(rs)-Pos(')',rs));{cutting header}
rs:=Copy(rs,Pos('(',rs)+1,Pos(')',rs)-Pos('(',rs)-1);{cut number}
if rs='' then l^.a^.points:=0
else Val(rs,l^.a^.points,res);{or Read(rs,l^.a^.points) for standard Pascal}
if res<>0 then error('Incorrect number of points!');
end;
end;
end{of answer header}
else
if Pos('P?',rs)=1 then
begin
rs:=Copy(rs,Pos('(',rs)+1,Pos(')',rs)-Pos('(',rs)-1);{cut number}
if rs='' then TotalPoints:=0
else Val(rs,TotalPoints,res);{or Read(rs,Totalpoints) for standard Pascal}
if res<>0 then error('Incorrect number of total points!');
end{of total points header}
else
begin
pStringsList(p)^.n:=New(pStringsList);
if pStringsList(p)^.n=nil then Error('No memory for string')
else
begin
pStringsList(pStringsList(p)^.n)^.p:=p;{set pointers}
p:=pStringsList(p)^.n;
pStringsList(p)^.n:=nil;
pStringsList(p)^.s:=rs;{set string}
end;
end;{of strings list processing}
end;{of headers processing}
end;{of file reading loop}
if l<>nil then ShowQuestion(l);
WriteLn('Total points:',PointsSum);
If TotalPoints<=PointsSum then WriteLn('Test passed!')
else WriteLn('Test failed!');
end.

NOPIK опубликован 11-02-2002 01:48 MSK     Click Here to See the Profile for NOPIK  Click Here to Email NOPIK     
P?()указатель проходного балла может служить комментарием ;-)
P?()*****************
P?()* Пример теста *
P?()*****************
Q?Почему для разделителя выбран вопросительный знак?
A?(1)Так надо, Вася!
A?(5)По правилам, невозможно его появление
после первого символа строки.
A?()Потому что он является признаком вопросительных предложений
И в ответах не употребляется.
Q?Очередной вопрос
A?()Очередной ответ
A?()Глупость это - тестировать людей в здравом уме!
P?(5)Минимальный балл для прохождения теста
sWap опубликован 12-02-2002 12:08 MSK     Click Here to See the Profile for sWap  Click Here to Email sWap     
Чуваки а я вам в следующий раз сюда прямо на форум исходничек дума или юникса кину. Вы чё мыло юзать не умеете, даваёте ещё тома Д.Кнута лить в прямом виде
;\
AlexR опубликован 13-02-2002 14:16 MSK     Click Here to See the Profile for AlexR  Click Here to Email AlexR     
Странно... Чё т не работает эта прога.
ozzy опубликован 13-02-2002 15:30 MSK     Click Here to See the Profile for ozzy  Click Here to Email ozzy     
Которая, моя или здесь на форуме?
NOPIK опубликован 13-02-2002 15:48 MSK     Click Here to See the Profile for NOPIK  Click Here to Email NOPIK     
Наверное, которая тут... Я ведь ее тут и писал - поэтому в Паскале может не работать :-)))
NOPIK опубликован 13-02-2002 15:54 MSK     Click Here to See the Profile for NOPIK  Click Here to Email NOPIK     
Нарочно в Trubo Pascal скопировал - работает... Правда, память без нужды ест, и я забыл проверку наличия ответов на вопрос при выводе... Но это сущие пустяки :-)))

СПРОСИТЬ  ОТВЕТИТЬ
Перейти:


E-mail | WWW.ИСХОДНИКИ.RU

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.