Selection statements in the program- example
1. Sum of two smallest number
Enter three integers and calculate the sum of the two smallest.
2. Order number
Enter three integers and examine whether the first is the highest and if it is the final order
3. Sign of the numbers
Determine if the entered number is called, zero, or negative.
4. Discuss solutions of the equation
Enter the parameters a and b, the equations a * X = b and discuss solutions of the equation
5. Formiranje stranica trougla
Enter the integers a, b, c, and examine whether the numbers of the triangles can be formed from these numbers.
6. Order number 2
Enter three integers a and b and c. and print their order from the largest to the smallest.
7. Athletics rating
Enter the result (through the standard input) that the competitor has achieved in the long jump and evaluate it. To jump over 8m score 10, 7.50-8.0 score 9, etc.
8. Volleyball
Determine whether the ball at the volleyball service will cross the height of the net, if the starting speed is in the vertical direction 2m / s, the height of the ball is 1.80 m and the net is at the height H meters (user input)
9. Determining the quadrant
Write a program that provides the angle that is loaded in the degrees that can be
greater than 360 and negative determines the quadrant to which it belongs
greater than 360 and negative determines the quadrant to which it belongs
10. New Year's Gift Packages
New Year Gift Package should contain X Chocolate, Y Candies and Z Pomorandzi.
Write a program to determine how much a gift pack can be made from
A chocolate, B candies and C pomorandzi
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
The whole number K is given from 1 to 2697. Determine which digit is on the K-to
position 101102103104 ... 998999 in pcs
are numbers printed from 101 to 999.
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
Pera, Mika and Laza are three brothers born on the same day, and Ana is their 3-year-old sister. Write a program to check if the entered number can be the sum of their years.
Input
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
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
Write a program that checks for a point in a given task with its coordinates whether it belongs to a given circle and a given rectangle whose sides are parallel to the coordinate axis.
Input
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
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
In a private school, a rule was introduced that determines the amount of discounts that students earn when enrolling in the next school year. Students with a great success earn a discount of 40% of the total tuition fee, with a good 20% and a good 10%. Also, students who have won a prize at a state competition earn a discount of 30% of the total tuition fee. If a student meets two criteria for discount, the criterion for which the discount is higher is applied. Based on the full amount of scholarship, average grades of students and information on awards from the competition, determine the amount that a student should pay when enrolling in the next academic year.
Input
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
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
In the country of Tarzania, there are only small coins (1, 2, 5 or 10 jukku). Sellers often have a problem with
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.
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.
Example
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).
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 >| |