ADDITIONAL TASKS FROM THE TOPIC - DATA AND DATA TYPES (C, C++, JAVA)
In this section, examples of tasks from the field of data and operators, with solutions, are given. Try to solve the examples on your own, and use the solution for checking or use it if, after a large number of attempts and a lot of effort, you still fail to solve the task on your own.
The solution will be displayed by clicking the button next to the assigned task.
The tasks are colored in different colors depending on the difficulty:
The solution will be displayed by clicking the button next to the assigned task.
The tasks are colored in different colors depending on the difficulty:
- Green - easy tasks
- Yellow - tasks of medium difficulty
- Red - more difficult tasks
Task 1-Picture frames:On the table there are picture frames of different dimensions, but they are all rectangular in shape. Based on the given width and height of the frame in millimeters, the program should determine the area of the frame in square millimeters. Input: One line of standard input contains two integer values X and Y (X≤300, Y≤300) representing the width and height of the image frame expressed in millimeters. Output One integer representing the area of the frame in square millimeters and one real number representing the area of the frame in square centimeters. Example Input 456 785 Output: 357960 3579.60 |
Task 2-Group of workers:n workers do the job in s hours. Write a program that determines how many hours the work will be completed if more are added
m of workers? Input The three lines of the standard input respectively contain the natural number n, the real number s and the natural number m. Output One real number, rounded to two decimal places, representing the number of hours required to complete the job if more are added m workers to the initial number of n workers. Example Input 1 3 1 Output 1.5 |
Task 3-Body movement:The body begins to move from rest with a constant acceleration of a(m/s2). What is its speed after time t(s) 5s>t>30s How far does he travel in this time? Input The two lines of the standard input respectively contain the acceleration a in m/s2 and the time t in seconds. Output Two real numbers, rounded to two decimal places, representing the speed in m/s and the distance traveled in meters. Apply the format given in the example. Example Input 2 20 Output v=40 m/s s=400m |
Task 4-Exchanging digits:Write a program that exchanges the units digit and the hundreds digit in a given natural number.
For a number with less than three digits, we consider the missing digits equal to 0. Input The first line of standard input contains a natural number. Output The number obtained after exchanging the units digit and the hundreds digit. Example Input 2349 Output 2943 |
Task 5-Middle of the interval:There are houses in one long street. All houses in the street are marked with natural numbers. Ana lives in house number a, and Boris lives behind her, in house number b. Viktor lives in a house right in the middle between Anna and Boris. Write a program that determines the number of the house where Viktor lives (if there is an even number of houses between Anna and Boris, Viktor lives in the one closer to Anna).
Input: Two integers are entered from the standard input:
Output:
Print one whole number on the standard output - the number of the house where Victor lives. Example 1 Input 432457 562321 Output 497389 Example 2 Input 2 9 Output 5 |
Example 3 Input 2000000000 1999999998 Output 1999999999 |
Task 6-Operations by module:Write a program that determines the last three digits of the sum and the last three digits of the product of four input integers.
Input: In each line of the standard input, one integer from the interval [1..999][1..999] is entered. Output: The number determined by the last three digits of the sum and the number determined by the last three digits of the product of the entered numbers are printed on the standard output (any leading zeros do not need to be printed). Example 1 Input 999 999 999 999 Output 996 1 |
Task 7-Distance of points:
Write a program that calculates and prints the distance between points given their coordinates.
Input Four real numbers are entered from the standard input, each in a separate line. The first two numbers Ax and Ay represent the coordinates of the point A=(Ax,Ay), while the second two numbers Bx and By represent the coordinates of the point B=(Bx,By). Output Print a real number representing the distance between points A and B, rounded to five decimal places, on the standard output. Example Input 0 0 1 1 Output 1.41421 |
Task 8-Product of the digits of a three-digit number:
9. Converting an angle
10. Time conversion
11. Travel
The family went on vacation by car. By car, they have to cover kilometers moving at a constant speed of v[km/h]. Write a program that determines how many kilometers will be covered in t hours.
Input The first line of the standard input contains the real value v, and the next line the real value s, which respectively represent the speed expressed in km/h and the planned distance traveled in kilometers. Output One real number rounded to two decimal places representing the required time in hours. Example Input 60 1050 Output 17.50 Source: Loop, Arithmetic.Formulae.Motion |
Solution-video |
12. Distance between houses
Pera and Mika live in the same street, Mika's house is further from the school. They go to school the same way, leave home at the same time and move evenly. Pera moves with speed v1m/s, and Mika moves with speed v2m/s (v2>v1). Write a program that determines the distance between their houses, if after t seconds Mika was d meters behind Pera.
Entrance Four real numbers are entered which respectively represent Pera's movement speed (v1), Mika's movement speed (v2), the speeds are expressed in m/s, the number of seconds (t) and the distance between Pera and Mika in meters (d). Each piece of data is in a separate line of standard input. Exit On the standard output, display a real number, to two decimal places, that represents the distance between their houses. Example Entrance 1.6 2.1 10 30.0 Exit 35.00 Source: petlja.org/biblioteka/r/problemi/Zbirka-stara/rastojanje_kuca |
Solution-video |