Subscribe and read
naytsіkavishі
statti first!

Logic speech. Topic: Logical data type. Logical operations not, and, or. Significance of logical verses. Independent work

Choose from a teacher independent work from the lower rights.

1. Calculate the value of the virus:

a) sqr(x)+sqr(y)<=4 при x=0.3, y=-1.6;

b) k mod 7 = k div5-1 with k = 15;

c) odd (trunc (10 * p)) at p = 0.182;

d) not odd(n) for n=0;

e) t and (p mod 3 = 0) at t = true, p = 101010;

e) (x * y<>0) and (y>x) with x=2, y=1;

g) (x * y<>0) or (y>x) when x=2, y=1;

h) a or (not b) with a=False, b=True;

2. Write down in Pascal the vіdnoshnja, istne with vikonnі znachenї mind and hibne іnakshe:

a) integer k is subdivided by 7;

b) equal does not have a speech root;

c) the point (x, y) lies near the radius R with the center at the point (1,0);

d) a natural number N is a square natural number;

f) x = max(x, y, z);

g) (do not win the operation)

h) wanting one of the logical changes and that b may be True;

i) offending logical changes a and b may be True.

3. Specify the order of operations for counting viruses:

a) a and b or not c and d;

b) (x> = 0) or not c і d.

4. Calculate the following numbers with a=True, b=False:

a) a or b and not a;

b) (a or b) and not a;

c) not a and b;

d) not (a and b)

5. Write down in Pascal viraz, it is true with vikonannі assignedї mind and hibne іnakshe:

a) x lie down;

b) lie down in a windbreak position;

c) * x overlap or [-1, 1];

d) * х lie down in a pose with arms and [-1, 1];

e) skin from the numbers x, y, z is positive;

g) the same numbers x, y, z are not positive;

h) more than one of the numbers x, y, z is positive;

i) logical change and may value True, logical change and may value False;

j)* рік із serial number у є is a leap year (рік is a leap year, so its number is a multiple of 4, prote z a multiple of 100 leap years is more than a multiple of 400, for example, 1700, 1800 and 1900 are not leap years, 2000 is a leap year).

6. Paint on the area (x, y) area, in the yakіy and only in the yakіy the viraz is assigned:

a)* (y>=x) and (y+x>=0) and (y<=1);

b) (sqr(x)+sqr(y)<1) or (y>0) and (abs(x)<=1);

c) (trunc (y) = 0 and (round (x) = 0);

d)* (abs(x)<=1)>(abs(y)>=1);

e) (sqr(x)+sqr(y)<=4)=(y<=x).

7) Є smart operator:

writeln('hooray!')

writeln('bad...')

You can replace yogo with offensive operators:

a) Yes, d=10 b) Yes, no (d=10)

writeln ('hooray!') writeln ('hooray!')

writeln('bad...'); writeln('bad...');

c) No way (d=10) d) No way (d)<>10)

writeln ('bad...') writeln ('bad...')

writeln('hooray!'); writeln('hooray!');

8) What will be the values ​​of the change j, k after the change of the smart operator:

as a rule

Note. As a result of the change of the dec(k,2) operator, the value of the changed k changes by 2.

Lesson from the series " Geometric Algorithms»

Hello dear reader!

Today we look at one typical task from a series of geometric algorithms. Let's write a function, like a reverb belonging quite points of contact, given by the coordinates of its cob and end.

To implement the alignment operation on speech data, we will write two more functions: the EqPoint () function, as it is reversed, two points on the plane and the RealMoreEq () function, we will use the ">=" (more or less) for reverification. The reason for the introduction of special functions is already known.

Manager. Reverse, linger chi dot vіrіzku.

Let the dots - pochatkova and terminal dots vіdrіzka. - A fair point on the plane.

Vector with cob y point and end y point matime coordinates (x2-x1, y2-y1).

If P(x, y) is a sufficient point, then the coordinates of the vector are complete: (x-x1, y – y1).

Krapka R is indispensable in the following way:

Program geom3; Const _Eps: Real = 1e-3; (calculated accuracy) var x1, y1, x2, y2, x, y: real; Function RealEq(Const a, b:Real):Boolean; (Strictly one) begin RealEq:= Abs(a-b)<= _Eps End; {RealEq} Function RealMoreEq(Const a, b:Real):Boolean; {больше или равно} begin RealMoreEq:= a - b >= _EpsEnd; (RealMoreEq) Function EqPoint(x1,y1,x2,y2:real):Boolean; (There are two points on the plane) begin EqPoint:=RealEq(x1,x2)and RealEq(y1,y2) end; (EqPoint) Function AtOtres(x1,y1,x2,y2,x,y:real):Boolean; (Checking whether point P belongs to P1P2) Begin If EqPoint(x1,y1,x2,y2) Then AtOtres:= EqPoint(x1,y1,x,y) (points P1 and P2 are incremented, the result is incremented points P1 and P) Else AtOtres:= RealEq((x-x1)*(y2-y1)-(y-y1)*(x2-x1),0)and (RealMoreEq(x,x1)and RealMoreEq(x2,x)Or RealMoreEq(x ,x2)and RealMoreEq(x1,x)) end; (AtOtres) begin (main) writeln(Enter coordinate point: x1,y1,x2,y2,x,y"); readln(x1,y1,x2,y2,x,y); ,y2,x,y) then writeln("So.") else writeln("Hi.); end. (main)

The results of the vikonannya program.

Enter coordinate point: x1, y1, x2, y2, x, y
0.5 1 2.5 2.8 1.203 1.633
So.

The results of testing with the GeoGebra program:


Today we have written the function AtOtres() , as if we were checking the proximity of a certain point to a rail given by its coordinates.

Introduced two functions: EqPoint() and RealMoreEq() to implement matching operations on speech data. The first one is reversed, two points on the plane are used, the other one is victorious for reverification of the “> =”.

At the next stage, on the basis of the previously written procedures, we will write a procedure for assigning the coordinates of the cross point of two windings.

Why do I say goodbye to you. To zustrіchі on the coming lesson.

. X lie down in the air;
x lie down in a windy position;
x overlap or [-1,1];
x lie down in a vіrіzkom pose or [-1,1].
3.
Explain the structure and rules of vikonannya smart operators.
4.
Write down the assignment for the look of one smart operator:
cos
2
x, at 0x at =
1-sin
2
x, otherwise.
5.
z
int z=0, x=1, y=

1;

80 Programming of linear algorithms in the system C++Builder
if (x>0) if (y>0) z=1; else z=2;
6.
Yake the meaning of mother is changed z after vikonannya operators:
int z=0, x=

1,y=1;
if (x) ( if (y>0) z=1;) else z=2;
7.
Yake the meaning of mother is changed z after vikonannya operators:
int z=0, x=0, y=1;
if (x) ( if (y>0) z=1;) else z=2;
8.
Yake the meaning of mother is changed z after vikonannya operators:
int z=0, x=3, y=1;
if (x) ( if (y) z = 1;) else z = 2;
9.
Show pardons for upcoming operators:
if (1
elsex=0; y+= 1;
10.
int z=0, x=0, y=1;
if (! x) ( if (! (y)

1)) z = 1;) else z = 2;
11.
Like the value of the matime is changed z after the victor of the operators:
int z=0, x=1, y=1;
if (! x) ( if (! (y)

1)) z = 1;) else z = 2;
12.
Find pardons from a fragment of the program:
(int n, x; switch (k) case + : x:=x-4 break; case

-

,

*

, x = 5;
}
What rules have been broken and how can pardons be corrected?


81
3.4
Individual orders before distribution 3
A skin student needs to complete two tasks of the first and the other equal folds.
The manager of the first level of folding.
1.
You are given a positive integer number. Write a program, like a friend true or false indebtedly, depending on the value of the number assigned to the mind: the sum 1 and 4 digits are more expensive 2 and 3 digits.
2.
Given numbers x, y. If x and y are negative, then the skin value should be replaced by a module; if only one of them is negative, then the offending value is increased by 5.5; in other cases, the offense value changed 10 times.
3.
Given numbers x, y. If x and y are positive, then the skin value will change by 5 times; if the offending value lies in the range [-3, 9], then the offending value is replaced by 0; in other cases x and y increase by 3.
4.
Given actual numbers x, y (xy). Least of these two numbers, replace them with their sum, and more - with their sub-creation.
5.
If the sum of three pairwise different real numbers x, y, z is less than 1, then the least of these three numbers should be replaced by the sum of the other two; in a different way, replace less x and y with the sum of the two values ​​that are left out.
6.
Given numbers a, b, c, d. Yakscho a b>c>d, numbers without change; Otherwise, replace all numbers with squares.
7.
Signify that the six-digit number is lucky. (The number is called lucky, as the sum of the first three digits is equal to the sum of the remaining three digits.)
8.
true or false fallow, depending on whether the value of the number is assigned to the mind: for sufficient real numbers a, b, c, it is significant, what is equal to ax
2
+bx+c=0 I want one more solution.

82 Programming of linear algorithms in the system C++Builder
9.
To complete the impending task, write a program, for others true or false indeterminately, depending on the value of the number assigned to the mind: calculate the value of the sum of the first two digits of the given four-digit number of the sum of the two remaining numbers.
10.
Deakim initial mortgage dіyut taki rules accept. Applicants add up two drinks, as they are assessed for
100 balls of leather. If an applicant gains at least 150 points, then he gives the right to join the day of graduation, from 100 to 149 - to the party of graduation; lower than 100 points means graduation from the receptionist. Write a program, yak, stalely in the sum of scoring points, showing the applicant the right to enter.
11.
Write a program using the choice of the operator to choose, as it allows you to take the verbal description of the icon. (1 - "bad", 2 -
"unsatisfactory", 3 - "satisfactory", 4 - "good", 5 -
"vіdminno".)
12.
To complete the impending task, write a program, for others true or false indeterminately, depending on whether the chi is assigned to the mind: choose, chi є the middle digits of a given three-digit number are the same.
13.
Write a program, like a friend true, as the date d1, m1 forward (within the framework of the date) d2, m2 that meaning false in a different direction.
14.
Write a program for the help of the operator to choose, as for the first letter of the name, I will display it on the screen
(Ivan, Petro, Mykola, Volodymyr, George).
15.
Write a program using the same choice of the operator as for the entered number 0≤ k≤ 5 other names I will name Russian and English digits.
16.
Given a number k (1

k

365). It means that it will be the k-th day of fate - a vihіdny chi worker, like 1 sіchnya - monday.
17.
Given deisne number x. Calculate f, like:











sin
,
1 0
,
0 5
2 11 2
vipadkah
reshti
in
x
x
x
at
x
x
x
at
f

Programming from multiples of one-world arrays
83 18.
Given a number x. Write a program to calculate f:












34 5
,
12 3
lg ln
,
3 5
1 3
2 4
vipadkah
reshti
in
x
x
x
at
x
x
x
at
f
19.
Write a program using the choice of the operator to select, as for the first letter, name the place to display on the screen the name of the place (Kursk, Moscow, Tula, Novgorod, Voronezh).
20.
Write a program with the choice of the operator to choose, as for the first letter of the name, to display the name on the screen in the same way (Ivanov, Petrov, Sidorov, Mishkin, Shishkin).
21.
Given the coordinates of the center and the radius of the stake. Indicate the location of the main point, which can have coordinates (x, y), dovkіllya.
22.
Write a program using the operator’s choice of choice, after the first letter entered, name the creature over the name of the creature (dog, gut, giraffe, ken, mavpa).
23.
Given three different numbers a,b,c. Sort qі numbers after the growth in such a rank, sob a proved to be smallest number, b- average number, c- The most.
24.
Write a program for the help of the operator to choose, such as the number (type 1 to 7) to display the name of the day of the day.
25.
Write a program for the help of the operator to choose, such as the number (type 1 to 12) to enter the name of the month of the year.
26.
Write a program using the choice of the operator of choice, so that after the first letter entered, name the season of rock and another name of the season of rock.
27.
Given a five-digit positive integer number. Write a program, like a friend true or false fallow, depending on the number of points assigned: the sum of 1, 3 and 5 digits is greater for additional 2 and 4 digits.
28.
You are given a positive integer number. Write a program, like a friend true or false fallow,

84 Programming of linear algorithms in the system C++Builder win chi nі assigned mind: arithmetic mean 1 that
4 digits more sumi 2 and 3 digits.
29.
Given a number i three-digit number the tens system has numbers. If the number is taken from the highest digit of the number, then calculate the sum of the digits of the number. If the number is picked up from the middle digit of the number, then calculate the additional digits of the number. If a digit is combined with the smallest digit of the number, then calculate the arithmetic mean of the digits of the number. If you don’t mind the mind, then calculate the average geometric digit of the number.
30.
Given a figure and a three-digit number in the tenth system of numbers. If a digit is counted with the highest digit of the number, then calculate the arithmetic mean of the digits of the number. If the number is picked up from the middle digit of the number, then calculate the geometric mean of the digits of the number. If a digit is combined with the smallest digit of the number, then calculate the sum of the digits of the number. If the mind is not beaten, then calculate the additional digits of the number
The task of another level of folding.
1.
Given a two-valued positive number in a triple number system. Write a program, how to enter the name of the digits of the Russian number, as the older digit of the number is younger, otherwise
- on the English language.
2.
You are given a two-valued positive number in the fivefold number system. Write a program, how to enter the name of the digits of the number in English, as the older digit of the number is younger, otherwise
- my Russian.
3.
You are given a two-valued positive number in the fivefold number system. Write a program, how to enter the name of the digits of the number in English, so that the older digit of the number is young exactly 2 times, otherwise
- my Russian.
4.
Given a two-valued positive number in a triple number system. Write a program, how to enter the name of the digits of the number of my Russian, as the older digit of the number is less for the younger, otherwise
- in English language.

Programming from multiples of one-world arrays
85 5.
You are given a two-valued positive number in the fivefold number system. Write a program, how to name the digits of the Russian number.
6.
Given a two-digit positive number in the octal number system. Write a program, how to name the digits of the Russian number.
7.
Given a two-digit positive number in the octal number system. Write a program, how to enter, as if the oldest digit is less than the second youngest digit, name the digits of the number in English, otherwise

my Russian.
8.
Given a two-digit positive number in the septenary number system. Write a program, how to enter, as if the numbers were sorted out for falling, name the digits of the number in English, otherwise

my Russian.
9.
Two digits are given in the tenth number system. Write a program, how to display the name of my English digits sum of tsikh digits.
10.
Two digits are given in the tenth number system. Write a program, how to display the name of my Russian number, the extraction of these numbers.
11.
Two digits are given in the tenth number system. Write a program, how to display the name of my Russian number, the module of the difference between these numbers.
12.
Two digits are given in the tenth number system. Write a program, how to display the names of the numbers in English, my private and the excess of the whole subdivision of these numbers.
13.
The given number is a two-digit positive number in the nine-digit number system. Write a program, how to enter, so that the older digit is larger than the second younger digit, name the digits of the number in English, otherwise

my Russian.
14.
The given number is a two-digit positive number in the nine-digit number system. Write a program, how to enter the name of the digit of the number, which is more significant, in English, and naming the digit of the number, which is less significant,

my Russian.

86 Programming of linear algorithms in the system C++Builder
15.
The given number is a two-digit positive number in the septenary number system. Write a program, how to enter the name of the digit of the number, which is more significant, in English, and naming the digit of the number, which is less significant,

my Russian.
16.
You are given a two-digit positive number in the six-digit number system. Write a program, how to enter the name of the digits of the number in English mine.
17.
Given two double-valued positive numbers in the triple number system. Write a program, how to name the numbers of the sum of these numbers in Russian mine.
18.
Given two double-valued positive numbers in a two-digit number system. Write a program, how to name the numbers of the sum of these numbers in English language.
19.
You are given a two-valued positive number in the fivefold number system. Write a program, how to enter, as if the numbers are spread out for growth, name the digits of the number in English, and otherwise

my Russian.
20.
You are given a two-digit positive number in the six-digit number system. Write a program, how to enter, if the older digit is greater for five times the younger digit, name the digits of the Russian number, and otherwise

in English language.
21.
Given two digits in the octal number system. Write a program, how to display the name of my Russian digits, the module of the difference between digits.
22.
Given two digits in the octal number system. Write a program, how to name the Russian my sum of two numbers.
23.
The given number is a two-digit positive number in the septenary number system. Write a program, how to enter, if the older number is bigger than the second one, name the digits of the Russian number, and otherwise

in English language.
24.
Given a double-digit positive number in the highest number system. Write a program, how to enter the name of the digit of the number, what can be more significant, Russian mine, and on-

Programming from multiples of one-world arrays
87 ringing digits of a number, what can be less significant,

in English language.
25.
The given number is a two-digit positive number in the septenary number system. Write a program, how to enter the name of the digits of the number, which may have a value less than 4, Russian mine, and the name of the digits of the number, which may have a value greater or more expensive 4,

in English language.
26.
You are given a two-digit positive number in the six-digit number system. Write a program, how to enter the name of the digits of a number, which may have a value less than 3, Russian mine, and name the digits of a number, which may have a value greater or more 3,

in English language.
27.
Two first letters are given (without register adjustment, like small, so great) name the month of fate. Write a program, how to name the month of my Russian fate again.
28.
Two first letters are given (without register adjustment, both small and large) of the day of the day. Write a program, how to call out the name of the day of my day in Russia.
29.
In the old Japanese calendar, a 60-row cycle was adopted, which consisted of five 12-row cycles. The subcycles were designated by the names of the color: green, red, yellow, white and black. In the middle of the skin subcycle, the rocks were named after creatures: bee, cow, tiger, hare, dragon, snake, horse, wolf, mavpi, chicken, dog and pig (1984 r_k - r_k green squir - on the cob of the black cycle). Write a program, how to enter the number of the day of our birth and other names for the old Japanese calendar.
30.
The given number is a two-digit positive number in the nine-digit number system. Write a program, how to enter the name of the digits of a number, which may have a value greater than 5, Russian mine, and name the digits of a number, which may have a value less or more 5,

in English language.

88 Programming of linear algorithms in the system C++Builder
4 PROGRAMMING CYCLE
ALGORITHMS FOR THE C++BUILDER SYSTEM
Whose distribution is necessary for the film cycle
C++, learning how to program cyclic algorithms
so, compilation and adjustment of programs.
4.1
Basic understanding
my C++Builder I base three statements on the loop:
1.
Cycle from Peredumovoy ( while);
2.
Cycle from postum ( do);
3.
Cycle with a lichnik ( for).
Cycle operator with change of mind while (Figure 4.1):
while(umova) (tіlo cycle)
Figure 4.1

Scheme for the loop operator algorithm while
What is the result of the calculation? true(True), the cycle is over and the transition is renewed until the mind is rechecked. What is the result of the calculation? false(nonsense), then exit from the loop and go to the operator that follows the cyclic operator while.
Yakshcho before the first vikonanny cycle of the meaning of virazu bulo false, The body of the cycle is not beaten and the transition to the next operator is made.
Umov
Tіlo cycle
So
Hi

Programming from multiples of one-world arrays
89
Butt:
Calculate the sum of unpaired numbers in the interval from 1 to 10.
( int k = 1, s = 0; while (k (s + = k; k + = 2;);
}
}
Loop operator with posthum do (Figure 4.2):
do(thіlo cycle) while(Umova); so no wits
Tіlo cycle
Baby 4.2

Scheme for the loop operator algorithm do…while
Umov's words for a logical type, for a cycle - one simple or warehouse operator.
Body loop operator

Changes of a logical type are described for an additional identifier Boolean . The stench can take on more than two meanings - False (nonsense)і True (Truth). The stench is described at the distribution of the inventory of the change. Var<имя>: Boolean;

Up to logical viraziv can enter:

n logical values,

n operations blue (<- меньше, >- More<=- меньше или равно, >=- more or one,<>- Not one, = - one).

n logical operations And, Or, Not

n diff. other functions


Movie Turbo Pascal has logical operations that can be converted to a different logical type. These operations are not, and, or that xor.

Operation not(not) I can have one operand and make it logically listed. The result of the operation is not False, because the operand is true, and True, because the operand can be false. So, not True False (not true є nonsense) not False True (untrue є true).

Operation result and(i) є is true, only as insulting її operands are true, and nonsense in all other ways (logical plural).

Operation result or(or) є istina, as if the її operands were true, and hibny only once, if the offending operands were pardoned (logically folded).

Logical operations, blueprint operations and arithmetic operations are often summarized in one expression. When you see it blue, how to stand left-handed and right-handed in the sign of a logical operation, you can put it in the arms, the shards of a logical operation can highest priority. The following priority of operations has been taken into account:

2. and, *, /, div, mod

3. or, +, -

4. operations blue (<- меньше, >- More<=- меньше или равно, >=- more or one,<>- Not one, = - one).

In addition, the order of operations can be changed by the arms. For example, for a logical expression, we can arrange the order diy:

AorBandnot(AorB)


The back of the head is placed in the arms of the operation either, and then the operation not, and, or. As a substitute for changing A and the values ​​True and False, then, victoriously looking at the order of the other, we take the value of the entire range equal to True.

Right 5: . Write down the score and calculate the value of viruses

with a=10, b=20, c=true, d=false: a)(a>5) and (b>5) and (a<20) and (b<30);

b) not (a<15) or not (b<30);

c) c or d and (b=20).

Uvaga ! Pascal does not have the ability to introduce logical data beyond the help of the read operator. However, the view value of the changed boolean type is passed behind the help of the write operator. For example, after the write (5>2) statement fails, True will be displayed on the screen.

Home meals and tasks:

1. How can the logical change be described and what meaning can it take?

2. What can enter up to logical viraziv. Navedіt applications of the simplest logical virazіv.

3. Tell me about logical operations in my Pascal. Navedіt butt stock logical virazіv.

4. What is the priority of different operations in Pascal. Point an example.


Manager:

№19.

A. cile k is subdivided by 7;

B. Wanting one or more of x, y guys;

Р. x=max(x, y, z), then x is the largest of the three numbers x, y, z;

D. (do not win the operation)

E. wanting one of the logical changes and that b may be True;

G. offensive logical changes and and b may be True.

№20. Indicate the order of operations for the calculation of viruses:

a) a and b or not c and d; b) (x> = 0) or not c і d.

№21. Calculate the following numbers with a=True, b=False:

a) a or b and not a; b)(a or b) and not a; in) not a and b; G) not (a and b)

№22. Fold the program: At the entrance exams, the applicant put together physics, computer science, TV. Admittance is necessary, as it takes 5 s of computer science and you will score a sum of points for three drinks no less than 13. Is it true, what are the results (True / False)?

§ 8. Development of tasks on the topic “Linear programs. Logic values.

Ex. 7 . Calculate the value of the virus:

a) sqr(x)+sqr(y)<=4 при x=0.3, y=-1.6;

b) k mod 7 = k div5-1 with k = 15;

c) odd (trunc (10 * p)) at p = 0.182;

d) not odd(n) for n=0;

e) t and (p mod 3 = 0) at t = true, p = 101010;

e) (x * y<>0) and (y>x) with x=2, y=1;

g) (x * y<>0) or (y>x) when x=2, y=1;

h) a or (not b) with a=False, b=True;

Ex. eight. Write in Pascal viraz, it’s true with the vykonannі zaznachenї mind and hibne іnakshe:

a) x lie down;

b) lie down in a windbreak position;

c) * x overlap or [-1, 1];

d) * х lie down in a pose with arms and [-1, 1];

e) skin from the numbers x, y, z is positive;

g) the same numbers x, y, z are not positive;

h) more than one of the numbers x, y, z is positive;

i) logical change and may value True, logical change and may value False;


j)* рік із serial number у є is a leap year (рік is a leap year, so its number is a multiple of 4, prote z a multiple of 100 leap years is more than a multiple of 400, for example, 1700, 1800 and 1900 are not leap years, 2000 is a leap year).

Ex. nine . Draw on the area (x, y) area, in the same and only in the same true values ​​of viraz:

a)* (y>=x) and (y+x>=0) and (y<=1);

b) (sqr(x)+sqr(y)<1) or (y>0) and (abs(x)<=1);

c) (trunc (y) = 0 and (round (x) = 0);

d)* (abs(x)<=1)>(abs(y)>=1);

e) (sqr(x)+sqr(y)<=4)=(y<=x).

Ex. ten ..The book costs X rubles. The purchaser has banknotes in denominations of 50, 10, 5, 1 rubles. How many of those banknotes do you need to take in order to pay for the book with the minimum amount of banknotes?

Changes of the logical type sound the values ​​as a result of the pairing of operations and mathematical operations (looked at the front busy), as well as for additional specific Boolean operations.

Movie Turbo Pascal has logical operations that can be converted to a different logical type. These operations are not, and, or that xor. For this topic, look at three logical operations. The meaning of the results of these operations is indicated in the table. Take a look at її.

Operation not(not) I can have one operand and make it logically listed. The result of the operation is not False, because the operand is true, and True, because the operand can be false. So,

not True False

not False True

Operation result and(i) є istina, only as insulting її operands of truth, and nonsense in all other ways.

Operation result or(or) є istina, as if there were some operands of її true, and hibniy only once, if the offending operands are pardoned.

manager . Try to determine the value of boolean operations for the following:

  1. A schoolboy stays at home during the winter holidays or somewhere else to go.
  2. Philip Kirkorov is a partner and a combine operator.
  3. Schoolchildren are boys and girls.

Logical operations, blueprint operations and arithmetic operations are often summarized in one expression. When you see it, how to stand left-handed and right-handed in the sign of a logical operation, it is necessary to put it in the arms, the shards of a logical operation may have a greater priority. The following priority of operations has been taken into account:

  • and, *, /, div, mod
  • or, +, -
  • operations are visible.

. The logical operation and is also called logical multiplications, and the logical operation or is called logical additions.

In addition, the order of operations can be changed by the arms. For example, for a logical expression, we can arrange the order dіy

A or B and not (A or B)

The back of the head is placed in the arms of the operation either, and then the operation not, and, or. As a substitute for changing A and the values ​​True and False, then, victoriously looking at the order of the other, we take the value of the entire range equal to True.

manager . Write down the score and calculate the value of the virus at a=10, b=20, c=true, d=false:

  • (a>5) and (b>5) and (a<20) and (b<30);
  • not (a<15) or not (b<30);
  • c or d and (b=20);

Respect! Pascal does not have the ability to introduce logical data beyond the help of the read operator. However, the view value of the changed boolean type is passed behind the help of the write operator.

For example, after the write (5>2) operator fails, True will be displayed on the screen.

Independent work

Choose from a teacher a task for vikonannya independent work from the lower rights.

  1. Calculate the value of the virus:

    a) sqr(x)+sqr(y)<=4 при x=0.3, y=-1.6;

    b) k mod 7 = k div5-1 with k = 15;

    c) odd (trunc (10 * p)) at p = 0.182;

    d) not odd(n) for n=0;

    e) t and (p mod 3 = 0) at t = true, p = 101010;

    e) (x * y<>0) and (y>x) with x=2, y=1;

    g) (x * y<>0) or (y>x) when x=2, y=1;

    h) a or (not b) with a=False, b=True;

  2. Write down in Pascal the vіdnoshennia, іtne іnіnіnіnіnі naznachenії mind and chibne іnakshe:

    a) integer k is subdivided by 7;

    b) the point (x, y) lies near the radius R with the center at the point (1,0);

    c) a natural number N is the square of a natural number;

    d) 0

    e) x = max (x, y, z);

    f) wanting one of the logical changes and that b may be True;

    g) offensive logical changes a and b may be True.

  3. Indicate the order of operations for the calculation of viruses:

    a) a and b or not c and d;

    b) (x> = 0) or not c і d.

  4. Calculate the following numbers with a=True, b=False:

    a) a or b and not a;

    b) (a or b) and not a;

    c) not a and b;

    d) not (a and b)

  5. Write in Pascal viraz, it’s true with the vykonannі zaznachenї mind and hibne іnakshe:

    a) x lie down;

    b) lie down in a windbreak position;

    c) * x overlap or [-1, 1];

    d) * х lie down in a pose with arms and [-1, 1];

    e) skin from the numbers x, y, z is positive;

    g) the same numbers x, y, z are not positive;

    h) more than one of the numbers x, y, z is positive;

    i) logical change and may value True, logical change and may value False;

    j) * r_k with a serial number y є is a leap (r_k is a leap year, so its number is a multiple of 4, prote s of multiples of 100 leap years is more than a multiple of 400, for example, 1700, 1800 and 1900 are not leap years, 2000 is a leap year).

  6. Draw on the area (x, y) area, in the same and only in the same true values ​​of viraz:

    a)* (y>=x) and (y+x>=0) and (y<=1);

    b) (sqr(x)+sqr(y)<1) or (y>0) and (abs(x)<=1);

    c) (trunc (y) = 0 and (round (x) = 0);

    d)* (abs(x)<=1)>(abs(y)>=1);

    e) (sqr(x)+sqr(y)<=4)=(y<=x).

  7. Є smart operator:
    if d<>10
    then
    writeln('hooray!')
    else
    writeln('bad...');

    You can replace yogo with offensive operators:

  8. What will be the values ​​of the change j, k after the change of the intelligent operator:
    if j>k
    then
    j:=k-2
    else
    dec(k,2);
    as a rule
    a) j = 3, k = 5;
    b) j = 3, k = 3;
    c) j = 3, k = 2.

Note . As a result of the change of the dec(k,2) operator, the value of the changed k changes by 2.

Join the discussion
Read also
Like the signs of the zodiac fit one to one at the kohanna - a horoscope of wisdom
Yak formed a share of the show's wives
We didn’t check the wedding: how to live the finalists of all seasons of “The Bachelor Maxim Chernyaev and Maria Drigola”