Programming Taskbook

Russian

E-mail:

Password:

User registration   Restore password

1000 training tasks on programming

©  M. E. Abramyan, 1998–2008

 

Additional types and procedures

Types and procedures described below will be available in a program if the PT4 unit is included in uses clause.


procedure Task(Name: string);

This procedure initializes a task named Name. It must be called at the beginning of the program. If the source code does not contain the Task procedure call then the program output the error message "The Task procedure is not called at the beginning of the program".

All subsequent calls of the Task procedure are ignored.

A task name must contain a name of a task group and an order number (for example, 'Begin3'). If the group name is invalid then the program output the error message with the list of all available groups. If the task number is invalid then the program output the error message with information about the range of the available task numbers for this group. The symbol "?" placed after the task name (for example, 'Begin3?') means that the program will be run in the demo mode.


procedure GetB(var A: boolean); procedure GetN(var A: integer); procedure GetR(var A: real); procedure GetC(var A: char); procedure GetS(var A: string); procedure GetP(var A: PNode);

These procedures must be used to input initial data values in the program. They must be called after the Task procedure, otherwise the program output the error message "The Task procedure is not called at the beginning of the program".

Each input procedure must correspond to the type of data item, otherwise the program output the following message: "Invalid type is used for an input data item" . For example, this message will be output if GetN procedure will be called for input a string.

In the case of input of more data than the task requires, the program output the error message "An attempt to input superfluous data". In the case of input of less data than the task requires, the program output the error message "Some required data are not input".


procedure PutB(A: boolean); procedure PutN(A: integer); procedure PutR(A: real); procedure PutC(A: char); procedure PutS(A: string); procedure PutP(A: PNode);

These procedures must be used to output results on the screen and compare obtained results with control data (i.e., correct results). They must be called after the Task procedure, otherwise the program output the error message "The Task procedure is not called at the beginning of the program".

Unlike the Get-procedures, parameters of the Put-procedures can be expressions (in particular, constants of a corresponding type). The used procedure should correspond to output data item, otherwise the program output the error message "Invalid type is used for an output data item".

In the case of output of more data than the task requires, the program output the error message "An attempt to output superfluous data". In the case of output of less data than the task requires, the program output the error message "Some data are not output".


procedure Dispose(var P: PNode);

This procedure overloads the standard Dispose procedure; it must be used in the tasks of the "Dynamic" group (see also PNode type description below).


type PNode = ^TNode; TNode = record Data: Integer; Next: PNode; Prev: PNode; end;

PNode and TNode types are used in the tasks of the "Dynamic" group. In the introductory tasks (Dynamic1–Dynamic2) and in the tasks devoted to stacks and queues (Dynamic3–Dynamic28) the Data and Next fields of the TNode record are used. In the tasks devoted to lists (Dynamic29–Dynamic80) all fields (Data, Next, Prev) of TNode record are used.

All initial and resulting pointers have PNode type in the tasks. They must be input and output by GetP and PutP procedures respectively. Students should not redefine the PNode and TNode types in their programs.

 

Designed by M. E. Abramyan and V. N. Braguilevsky

Last revised: 11.05.2008