Programming Taskbook

 E-mail: Password:

Russian 1100 training tasks on programming

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

 Main Tasks Examples PT for MPI-2

 Overview Input-output operations Task groups Begin Integer Boolean If Case For While Series Proc Func Minmax Array Matrix String File Text Param Recur Dynamic Dynamic (obj) Tree Tree (obj)
 Tasks | Task groups | Begin

# Input-output and assignment

All input and output data are real numbers in tasks of this group.

Begin1°. Given the side a of a square, find the perimeter P of the square: P = 4·a.

Begin2°. Given the side a of a square, find the area S of the square: S = a2.

Begin3°. The sides a and b of a rectangle are given. Find the area S = a·b and the perimeter P = 2·(a + b) of the rectangle.

Begin4°. Given the diameter d of a circle, find the length L of the circle: L = π·d. Use 3.14 for a value of π.

Begin5°. Given the edge a of a cube, find the volume V = a3 and the surface area S = 6·a2 of the cube.

Begin6°. The edges a, bc of a right parallelepiped are given. Find the volume V = a·b·c and the surface area S = 2·(a·b + b·c + a·c) of the right parallelepiped.

Begin7°. Given the radius R of a circle, find the length L of the circumference and the area S of the circle:

L = 2·π·R,        S = π·R2.

Use 3.14 for a value of π.

Begin8°. Given two numbers a and b, find their average: (a + b)/2.

Begin9°. Given two nonnegative numbers a and b, find their geometrical mean (a square root of their product): (a·b)1/2.

Begin10°. Two nonzero numbers are given. Find the sum, the difference, the product, and the quotient of their squares.

Begin11°. Two nonzero numbers are given. Find the sum, the difference, the product, and the quotient of their absolute values.

Begin12°. The legs a and b of a right triangle are given. Find the hypotenuse c and the perimeter P of the triangle:

c = (a2 + b2)1/2,        P = a + b + c.

Begin13°. Given the radiuses R1 and R2 of two concentric circles (R1 > R2), find the areas S1 and S2 of the circles and the area S3 of the ring bounded by the circles:

S1 = π·(R1)2,        S2 = π·(R2)2,        S3 = S1 − S2.

Use 3.14 for a value of π.

Begin14°. Given the length L of a circumference, find the radius R and the area S of the circle. Take into account that L = 2·π·R,    S = π·R2. Use 3.14 for a value of π.

Begin15°. Given the area S of a circle, find the diameter D and the length L of the circumference. Take into account that L = π·D,    S = π·D2/4. Use 3.14 for a value of π.

Begin16°. Two points with the coordinates x1 and x2 are given on the real axis. Find the distance between these points: |x2 − x1|.

Begin17°. Three points A, BC are given on the real axis. Find the length of AC, the length of BC, and the sum of these lengths.

Begin18°. Three points A, BC are given on the real axis, the point C is located between the points A and B. Find the product of the length of AC and the length of BC.

Begin19°. The coordinates (x1y1) and (x2y2) of two opposite vertices of a rectangle are given. Sides of the rectangle are parallel to coordinate axes. Find the perimeter and the area of the rectangle.

Begin20°. The coordinates (x1y1) and (x2y2) of two points are given. Find the distance between the points:

((x2 − x1)2 + (y2 − y1)2)1/2.

Begin21°. The coordinates (x1y1), (x2y2), (x3y3) of the triangle vertices are given. Find the perimeter and the area of the triangle using the formula for distance between two points in the plane (see Begin20). The area of a triangle with sides a, bc can be found by Heron formula:

S = (p·(p − a)·(p − b)·(p − c))1/2,

where p = (a + b + c)/2 is the half-perimeter.

Begin22°. Exchange the values of two given variables A and B. Output the new values of A and B.

Begin23°. Variables A, BC are given. Change values of the variables by moving the given value of A into the variable B, the given value of B into the variable C, and the given value of C into the variable A. Output the new values of A, BC.

Begin24°. Variables A, BC are given. Change values of the variables by moving the given value of A into the variable C, the given value of C into the variable B, and the given value of B into the variable A. Output the new values of A, BC.

Begin25°. Given an independent variable x, find the value of a function y = 3x6 − 6x2 − 7.

Begin26°. Given an independent variable x, find the value of a function y = 4(x−3)6 − 7(x−3)3 + 2.

Begin27°. Given a number A, compute a power A8 using three multiplying operators for computing A2, A4, A8 sequentially. Output all obtained powers of the number A.

Begin28°. Given a number A, compute a power A15 using five multiplying operators for computing A2, A3, A5, A10, A15 sequentially. Output all obtained powers of the number A.

Begin29°. The angle value α in degrees (0 ≤ α < 360) is given. Convert this value into radians. Take into account that 180° = π radians. Use 3.14 for a value of π.

Begin30°. The angle value α in radians (0 ≤ α < 2·π) is given. Convert this value into degrees. Take into account that 180° = π radians. Use 3.14 for a value of π.

Begin31°. A Fahrenheit temperature T is given. Convert it into a centigrade temperature. The centigrade temperature TC and the Fahrenheit temperature TF are connected as:

TC = (TF − 32)·5/9.

Begin32°. A centigrade temperature T is given. Convert it into a Fahrenheit temperature. The centigrade temperature TC and the Fahrenheit temperature TF are connected as:

TC = (TF − 32)·5/9.

Begin33°. X kg of sweet cost A euro. Find the cost of 1 kg and Y kg of the sweets (positive numbers X, AY are given).

Begin34°. X kg of chocolates cost A euro and Y kg of sugar candies cost B euro (positive numbers X, A, YB are given). Find the cost of 1 kg of the chocolates and the cost of 1 kg of the sugar candies. Also determine how many times the chocolates are more expensive than the sugar candies.

Begin35°. A boat velocity in still water is V km/h, river flow velocity is U km/h (U < V). The boat goes along the lake during T1 h and then goes against stream of the river during T2 h. Positive numbers V, U, T1T2 are given. Find the distance S covered by the boat (distance = time · velocity).

Begin36°. The velocity of the first car is V1 km/h, the velocity of the second car is V2 km/h, the initial distance between the cars is S km. Find the distance between the cars after T hours provided that the distance is increasing. The required distance is equal to a sum of the initial distance and the total distance covered by the both cars (total distance = time · total velocity).

Begin37°. The velocity of the first car is V1 km/h, the velocity of the second car is V2 km/h, the initial distance between the cars is S km. Find the distance between the cars after T hours provided that at the start time the distance is decreasing. This distance is equal to an absolute value of a difference between the initial distance and the total distance covered by the both cars.

Begin38°. Solve a linear equation A·x + B = 0 with given coefficients A and B (A is not equal to 0).

Begin39°. Solve a quadratic equation A·x2 + B·x + C = 0 with given coefficients A, BC (A and the discriminant of the equation are positive). Output the smaller equation root and then the larger one. Roots of the quadratic equation may be found by formula

x1, 2 = (−B ± (D)1/2)/(2·A),

where D = B2 − 4·A·C is a discriminant.

Begin40°. Solve a system of linear equations

A1·x + B1·y = C1,
A2·x + B2·y = C2

with given coefficients A1, B1, C1, A2, B2, C2 provided that the system has the only solution. Use the following formulas:

x = (C1·B2 − C2·B1)/D,        y = (A1·C2 − A2·C1)/D,
where D = A1·B2 − A2·B1. Designed byM. E. Abramyan and V. N. Braguilevsky Last revised:01.01.2021