Download 1. (1 point) Write a program which asks the user for the coordinates

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
1.
(1 point) Write a program which asks the user for the coordinates (x0,y0) of the centre of a circle and
for the radius (r) of this circle, then asks the user for the coordinates (x,y) of a point, and next checks whether
the point (x,y) belongs to the circle (i.e., whether the distance between the point and the centre of the circle
equals r; the distance should be calculated as a square root of the value:
(x-x0)2+(y-y0)2). The program should check whether the radius given by the user is positive.
2.
(2 points) Write a program which prints on the screen the following structure for the number of lines
(n) given by the user, e.g., for n=5:
1
24
3 9 27
4 16 64 256
5 25 125 625 3125
3.
(2 points) Write a program which asks the user for an integer value G, and then reads integer values
until the user enters 0. If the arithmetic mean of a value typed recently and the two values given in the two
preceeding iterations is greater than G, these three values should be printed. The ending 0 is not taken into
account. Example: for G=3 and the sequence of numbers: 1,2,3,5,3,-2,4,8,0 the program should display three
triples (subsequences):
2,3,5
3,5,3
-2,4,8
1.
(1 point) Write a program which asks the user for three positive numbers (a,b,c) and if they can be
lengths of the sides of a triangle (i.e., they satisfy all the appropriate conditions), computes the area of this
triangle using the Heron's formula (the area is equal to the square root of the value:
p(p-a)(p-b)(p-c), where p is a half of the perimeter of the triangle (the sum of the lengths of its sides).
2.
(2 points) Write a program which prints on the screen the following structure for the number of lines
(n) given by the user, e.g., for n=5:
1
02
147
0 4 8 12
1 6 11 16 21
3.
(2 points) Write a program which asks the user for an integer value G, and then reads integer values
until the user enters 0. If the value typed recently and the two values given in the two preceeding iterations
are all divisible by D, these three values should be printed. The ending 0 is not taken into account. Example:
for D=3 and the sequence of numbers: 1,-3,9,6,3,-2,12,-6,0 the program should display two triples
(subsequences):
-3,9,6
9,6,3
Related documents