Programming Taskbook


E-mail:

Password:

User registration   Restore password

Russian

SFedU

1100 training tasks on programming

©  M. E. Abramyan (Southern Federal University), 1998–2018

 

Tasks | Input-output operations

PrevNext


Input-output operations

If a task is solving with using Programming Taskbook then special input-output methods (procedures or functions) should be called in the student's program.

Brief information about input-output methods connected with the specific programming language is available from the Programming Taskbook window by pressing F1 key or «?» button on the window title (the Programming Taskbook window can be shown by using PT4Demo tool or running a program template created by PT4Load tool).

Brief description of input-output methods of programming languages that are supported by Programming Taskbook is shown below. See the Examples section for additional information.

Pascal language

Data input:
   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);
Data output:
   procedure PutB(A: boolean);
   procedure PutN(A: integer);
   procedure PutR(A: real);
   procedure PutC(A: char);
   procedure PutS(A: string);
   procedure PutP(A: PNode);

Starting from the version 4.13, you may also use the overridden Get and Put procedures for input and output respectively (for example, Get(A) or Put(A)). Also input functions without parameters are available: GetBoolean (or GetBool), GetInteger (or GetInt), GetReal (or GetDouble), GetChar, GetString, GetPNode. Each function returns the next element of input data.

See additional information about PNode type in the description of the Dynamic and Tree groups of tasks.

C++ language

Data input:
   void GetB(bool& a);
   void GetN(int& a);
   void GetD(double& a);
   void GetC(char& a);
   void GetS(char* a);
   void GetS(string& a);
   void GetP(TNode*& a);
Data output:
   void PutB(bool a);
   void PutN(int a);
   void PutD(double a);
   void PutC(char a);
   void PutS(char* a);
   void PutS(string a);
   void PutP(TNode* a);

A special input-output stream called pt may be used for input-output operations. For instance, function calls GetN(a); GetD(b); GetS(s); may be replaced by one stream-read statement as follows: pt >> a >> b >> s;

See additional information about TNode type in the description of the Dynamic and Tree groups of tasks.

Visual Basic language

Data input:
   Public Sub GetB(ByRef A As Boolean)
   Public Sub GetN(ByRef A As Integer)
   Public Sub GetD(ByRef A As Double)
   Public Sub GetS(ByRef A As String)
Data output:
   Public Sub PutB(ByVal A As Boolean)
   Public Sub PutN(ByVal A As Integer)
   Public Sub PutD(ByVal A As Double)
   Public Sub PutS(ByVal A As String)

The GetS and PutS procedures are intended for both string and character input-output because Visual Basic has no special type for characters.

.NET languages (C# and VB.NET)

Data input (C#):
   public static bool GetBool();
   public static int GetInt();
   public static double GetDouble();
   public static char GetChar();
   public static string GetString();
   public static Node GetNode();
Data input (VB.NET):
   Public Shared Function GetBool() As Boolean
   Public Shared Function GetInt() As Integer
   Public Shared Function GetDouble() As Double
   Public Shared Function GetChar() As Char
   Public Shared Function GetString() As String
   Public Shared Function GetNode() As Node
Data output (C#):
   public static void Put(params object[] a);
Data output (VB.NET):
   Public Shared Sub Put(ParamArray a() As Object)

Input-output operations for .NET languages are implemented as class methods of the PT class (the PT class is available for any student's program using Programming Taskbook).

The Put method may be used for output several data items of any admissible type (that is, any type that an input method is provided for).

See additional information about Node type in the description of the "object" variant of the Dynamic and Tree groups.

Python language

Data input:
   get()
   get_bool()
   get_int()
   get_float()
   get_str()
   get_Node()
Data output:
   put(a, ...)

All input methods are functions that return the next item of input data. The get method may be used for input data of any admissible type (that is, any type that an input method is provided for). The get_str method may be used for both string and character data input.

The put method may be used for output several data items of the bool, int, float, str, Node types and also for tuples and lists output (in the case of tuple/list output all items of the tuple/list are output sequentially).

See additional information about Node type in the description of the "object" variant of the Dynamic and Tree groups.

Java language

Data input:
   public static bool getBool();
   public static int getInt();
   public static double getDouble();
   public static char getChar();
   public static String getString();
   public static Node getNode();
Data output:
   public static void put(Object... a);

Input-output operations for Java language are implemented as class methods of the PT class (the PT class is available for any student's program using Programming Taskbook).

The put method may be used for output several data items of any admissible type (that is, any type that an input method is provided for).

See additional information about Node type in the description of the "object" variant of the Dynamic and Tree groups.

Ruby language

Data input:
   get
   get_bool
   get_i
   get_f
   get_s
   get_node
Data output:
   put(a, ...)
   a.put

All input methods are functions that return the next item of input data. The get method may be used for input data of any admissible type (that is, any type that an input method is provided for). The other functions allow to input data item of definite type: boolean data (true, false), integers (Fixnum), real numbers (Float), characters and strings (String), nodes of dynamic structures (Node).

The put method may be used for output several data items of the boolean data, Fixnum, Float, String, Node types and also for arrays output (in the case of array output all items of the array are output sequentially).

You can also use the put method without parameters; this method should be applied to the data item of the TrueClass, FalseClass, Fixnum, Float, String, Node, and Array type. For instance, you can output the integer value 1 by means one of the following expressions: put 1 and 1.put.

See additional information about Node type in the description of the "object" variant of the Dynamic and Tree groups.


PrevNext

 

  Рейтинг@Mail.ru

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

Last revised:
06.05.2018