Selection statements in the program- example
1. Sum of two smallest number
2. Order number
3. Sign of the numbers
4. Discuss solutions of the equation
5. Formiranje stranica trougla
6. Order number 2
7. Athletics rating
8. Volleyball
9. Determining the quadrant
greater than 360 and negative determines the quadrant to which it belongs
10. New Year's Gift Packages
Write a program to determine how much a gift pack can be made from
A chocolate, B candies and C pomorandzi
11. A digit at a certain position in the string
position 101102103104 ... 998999 in pcs
are numbers printed from 101 to 999.
The given series of numbers are three-digit numbers 101,102, etc. which are interconnected. Since the numbers in a series are three times less than the digits, then we can determine in which number in the given series the digit is in the k-th position by dividing k by 3. When the value k / 3 is added to 101. E.g. . if k = 5, k / 3 is 1, which indicates that k is the digit of the number 102. Now it remains to determine what is digit of that number is the one we are looking for. We can determine this by finding the remainder when dividing k and 3. In the previous example, this is 5% 3 = 2. So the second digit in number 102 is 0.
#include < iostream >
using namespace std ;
int main()
{
int k,b,c,i,p;//b-number in the sequence, c-digit at the k-position, and is the position of the digit in the located number from the array, p-degree with base 10 (1,10 or 100)
cin >> k ;
int b=101+k/3;
int i=k%3;
//i-position of the digit in the located number
int p=(int)pow(10,3-i);//p is the degree with base 10 to divide the located number to remove the required number of digits to the right
int c=(b/p)%10;//With% 10 we get the last digit in the transformed number
printf("%d",c);
return 0;
}
12. Sum of years
A positive natural number of less than 500 is entered from the standard input.
Output
At the standard output, show the word that if the entered number can be the sum of years Pere, Mike, Laze and Ana, and if it can not display the word, no.
Example
Input
27
Output
Yes
13. Point in rectangle and circle
From the standard input, the following real numbers are loaded (the numbers in the same row are separated by one space):
x, y - point coordinates,
x0, y0 - coordinates of the common center of the circle and rectangles,
r - radius of the circle,
w, h - length and width of the rectangle pages.
Output
On the standard output, print two lines of text. In the first line it should be written in the circle if the point (x, y) belongs to the circle with the center (x0, y0) radius rr, ie it is not in the circle if the point does not belong to the circle. In the second line it should be written in the rectangle if the point (x, y) belongs to the rectangle whose center (point) is at a point (x0, y0), whose sides are parallel to the coordinate axis and whose length is ww tj. h, that is, it is not in the rectangle if the point does not belong to the interior of that rectangle. The boundary of the circle (circles) and rectangles is considered to be their work.
Example
Input
1 1 0 0 1 2 2
Output
Not in the circle is in the rectangle
14. Tuition
The first line of the standard entrance contains the full amount of tuition (real number), in the second average grade of students (real number from 2.0 to 5.0) and in the third 0 if the student has no reward or 1 if there is one.
Output
The amount of scholarship to be paid by the student (rounded to the nearest whole number) is indicated in one line of the standard output.
Example
Input
4000 4.65 1
Output
2400
15. Change- Municipal Programming Competition 2014
by returning the curves, these developers help their programs to solve this problem. Write the program
KUSUR who will, for the purchase of value P, and for the value V given by the buyer, determine how much at least
money can be paid to the buyer as a buyer. Assume that the cashier has enough money
(1, 2, 5, or 10 jukuku), and that the exact amount of cusps is always returned (ie, the casserole will not give the chew or stay
obliged to the buyer). The values of P and V are two integers that are loaded from the first line of the standard input and
they are separated by one bland character.
Input
14 20
Output
2
Explanation: The seller will return a curfew with a total of two coins (one of 5 dinars and one of 1 dinars), and will not
return the curfew with three coins (every two dinars each).
Previous
|< Data examples in C/C++ |
Next
Loops - basic examples >| |