General information about the programming language
Qbasic
Language QBASIC (Beginner's All-purpose Instruction Code) developed by John Kimina and Thomas Kurtz at Dartmouth College, USA, in mid-1960
QBASIC has a special place among all high-level languages. From the outset it was conceived as a universal language for beginners, and software for QBASIC still included with your PC - as a mandatory element of the technology.
Here are some advantages QBASIC (in terms of mass user):
* Simple syntax;
* Ease of data and control structures;
* A large number of built-in commands and functions you can easily perform operations such as management of text and image display, processing of character strings, etc.)
A particular advantage of QBASIC should be considered to operate in a mode of interpretation, which dramatically simplifies the process of debugging programs: performance of almost every team can be checked immediately after writing (Shift + F5).

Arithmetic expressions

Program for BASIC language written in the form of a sequence of characters, which include Latin and n letters, Arabic numerals, punctuation marks (,,: " '?), Operators (* / - + <> =.), Special characters ( % &! # $).
To indicate the source data and calculations used variables.
The sequence of alphanumeric characters, beginning with the letter, called an identifier or variable name.
The numbers in the program is written in the decimal system, instead of a comma in decimal fractions written point: 0, - 17, 0.25, - 34.85.
Variables and numbers - just a special case of expression. More complex expressions are built from numbers and variables with signs of addition, subtraction, multiplication, division, exponentiation. ?,?, *, /, ^.
In calculating the values of expressions are the usual rules of precedence of operations:
1) exponentiation - ^
2) multiplication, and division *, /
3) addition, subtraction +, -
Actions to perform arithmetic expression from left to right, depending on their priority. In order to alter the natural course of action used parentheses. Expressions in parentheses are executed first.
The expression can use the following built-in functions:
ABS (x) - module x? x?
SQR (x) - square root of x (? X).
INT (x) - integer part of x
SIN (x) - sin x (the argument is the radian measure of angle)
COS (x) - cosine x
TAN (x) - tangent of x
ATN (x) - arctangent x
LOG (x) - natural logarithm of x
EXP (x) - exponent x
SGN (x) - the definition of the sign, x

Example. Write the rules BASIC mathematical expressions

1) X2 +2 X-5.12 (X ^ 2 +2 * X-5.12) / (X ^ 2 +12.51)
X2 +12.51

2) COS (X) - SIN (X) (COS (X)-SIN (X)) / (ABS (COS (X) + SIN (X)))
| COS (X) + SIN (X) |

Exercises

1. Which of the following strings are identifiers, and what does not.

a) X b) in X1) X? d) X1X2 d) AB e) ABCD
f) SIN r) SIN (X)) A-1 C) 2a l) MAX15

2. Write the rules BASIC following expressions:

a) b) 1 + X + X2 a) 1 +? X? +? 1 + X? g) A + B 2 C + D

d) A + B -1,7 e)? 1,2-9,8 X??? f)? X2 + Y2 +100
?1-Y (54,264-X) (2X +50,2)
E + F +0,5

3. Rewrite the following expressions, written in BASIC rules in traditional mathematical form:

a) A + B / (C + D) - (A + B) / C + D B) A * B / (C + D) - (C - D) / B * (A + B)
a) 1 + SQR (COS (X + Y) / 2) g) 2.56 + ABS (X ^ 2-Y ^ 6)
d) INT (X * 5.234 - A * (X + Y))

OPERATORS OF INPUT-OUTPUT

I assignment operator has the general form:

? the name of another variable
variable name =? arithmetic expressions
? number

As a result of an assignment variable, which stands to the left of the equal sign is assigned a value of another variable or value of the arithmetic expression or numeric value. To make the assignment operator could not be made, it is necessary that all the variables in the expression had some values were given above.

EXAMPLES 1. A = 0 2. C = 2 3. A = 2: B = 3
B = C C = (A + B) ^ 2 / 5

EXERCISES
1. Which of the following strings are the assignment statement:

a) A = B) A * X + B = C in) Z = Z +1 g) Y = Y e) - Y = Y

2. Set in the form of an assignment the following:

a) the variable Z to assign a value equal to half the sum of the values of variables
X and Y.
b) double the value of A,
c) the value of X to increase by 0.1,
d) change the sign of the variable Y.

3. Set using the assignment operators following:
a) A variable assign the value of the difference, and variable in-half sum of the values of variables X and Y.
b) A change set to twice the product of variables X and Y, and a variable to 0.

4) Given X, Y get? X? -? Y? X = 2,57 Y =- 5,379
1 +? X * Y?

Operators input-output

Operator input from the keyboard:

INPUT [ "text";] X1, [X2, X3 ... XN]
[] - Indicate that the options facing them is not mandatory;
X1, X2, ... XN - names of variables or identifiers.
As a result of this statement appears on the screen text, and the variables X1, X2, ... XN will be given the values from the keyboard.

Operators of the data block

READ X1, X2, X3, ... XN where X1, X2, .. XN - the names of variables
DATA C1, C2, C3, ... CN C1, C2, ... CN - is the value
As a result of these operators, the variable X1 will have the value C1, X2 takes the value C2 ...
Note! DATA statement can stand anywhere in the program. Read data from the repository DATA, you can use several operators READ.
Operator RESTORE returns read data at the beginning.

Operator display
PRINT S1 [; S2; S3 ...]< br /> where S1, S2 ... SN - lists
Lists are:
1) the name of the variable whose value is necessary to print;
2) an arithmetic expression whose value you want to print;
3) text enclosed in quotation marks.
Separator between the lists may be:
1), - lists are separated by step tab is 8 spaces;
2); - lists are printed close to each other.
To control the output using a special operator:
LOCATE X, Y
where X - number of the line screen 1 NOT "not" (negation)
= greater than or equal to> =
?not equal

Table of logic functions (truth table), where a and b-logical expressions.
A B NOT a NOT b a AND b a OR b
TRUE TRUE FALSE FALSE TRUE TRUE
TRUE FALSE FALSE TRUE FALSE TRUE
FALSE TRUE TRUE FALSE FALSE TRUE
FALSE FALSE TRUE TRUE FALSE FALSE

Sample entries of a logical expression: a + b> c AND d 8.
Logical operation NOT (negation) is performed over a simple logical expression: NOT (a> b)
Logical expression takes one of two values: TRUE (true) and FALSE (false). These expressions are used in the operators and branching cycle.
The current priority of operations is supported here:
first performed the operation in parentheses, then the logical multiplication, logical addition
Case records of logical expressions:

mathematical record entry in the language BASIC
(X> 0) and (Y0) AND (Y
-2 =- 2) AND (Y
?X10 (X10)
Adopted by the following priority of logical and arithmetic operations:
* Operation in parentheses;
* Operation is NOT;
* Operations AND, /, *;
* Operation OR, +, -;
* Relational operators.
Exercises
1. Calculate the value of a logical expression
a) X2-Y2 X) for X = 4, Y = 1
2. Write a logical expression, which have true value only if the specified conditions:
a) X> 0 and Y> 0 Y is not MAX (X, Y, Z)
b) is not true that X> 0 X, Y, Z are all equal
c) 2
Second quarter

Operators transition divided into two groups:
unconditional transfer operators and operators of conditional transfer.

Operator unconditional transfer.
It serves to transition from one program to another line, marked number or label.

General view of the operator: GOTO N

where N - number of lines or markings the operator to which the transition occurs in the program.
Examples:
1. X = 3 2. GOTO W
GOTO 7 ...
Y = 2 * XW PRINT "solution is obtained"
7 Z = 5 * X

Operators of conditional transfer
There are two forms of branching: complete and incomplete.











Accordingly, there are two types of operators: full and part-time alternatives.
I. Complete alternative (provided the team in the branches "YES" and in the branches "NO").
1) Linear form (operator is written on one line)
Condition is "YES"


IF condition THEN statement block 1 ELSE statement block 2


The condition is not satisfied "NO"

Work statement: depending on whether executed or not condition (condition - a boolean value, which may contain signs of comparison and logical operations). If the condition is true, the block of statements 1, if the condition is false, the block of statements 2.

EXAMPLE: IF A = 1 THEN PRINT "YES" ELSE PRINT "NO"
PRINT "END"
Here, the operators work as follows:
* If the condition A = 1 "true" statement is executed PRINT "YES" and PRINT "END";
* If the condition A = 1 "false", the statement is executed PRINT "NO" and PRINT "END".
*
2) The block notation:

IF condition THEN EXAMPLE:
block of statements CLS: INPUT a
branches "YES" IF a = 1 THEN
ELSE PRINT "YES branch is working"
block of statements PRINT a
branches "NO" ELSE
END IF PRINT "running branch NO"
PRINT a
END IF

II. Conditional operator incomplete alternatives:

IF condition THEN statement block

Examples of solving problems.
Example 1.Opredelit the largest of two numbers X and Y, entered the keyboard.
CLS: INPUT ""; X, Y
IF X> Y THEN
PRINT "The largest number X ="; X
ELSE
PRINT "MAXIMUM CHISLOY ="; Y
END IF
END
Example 2. Evaluate the function for any value of H.
?X2 +4 X-7, X
?Y = X2-3X +12, X> 2 Y = X ^ 2 +4 * X-7
ELSE
Y = X ^ 2-3 * X +12
END IF
PRINT "FUNCTION ="; Y; "X ="; X
END

Example 3. Calculate the function y = 3x2-5x +12 on the interval (-3,3) with step 1.
CLS: PRINT "Y", "X"
X =- 3
4 Y = 3 * X ^ 2-5 * X +12
PRINT Y, X
X = X +1
IF X
END
Example 4. Calculate the sum of integers from 10 to 20
S = 10 +11 +12 +...+ 20
CLS: S = 0: X = 10
5 S = S + X
X = X +1
IF X
PRINT "amount ="; S
END
Example 5. Calculate the product of odd numbers from 15 to 30
P = 15 * 17 * 19 *...* 29
CLS: P = 1: X = 15
7 P = P * X
X = X +2
IF X
PRINT "product ="; P
END

Cycles.
In the language QBASIC are two main ways of looping:
* Repeat unit commands a specified number (number) times (a cycle with counter);
* The cyclical repetition of the instruction block until done (or not done) a certain condition.

Cycle counter (FOR. .. NEXT) FOR ... NEXT

Operator cycle implements the algorithmic design, in which certain actions are repeated many times.

General view of the operator cycle with a counter:

FOR K = K1 TO K2 STEP K3 - header cycle
- Loop -
NEXT K - end of the cycle

Here, FOR - operator's name (translated "for"); K - variable (usually an integer), called the variable cycle management, K1, K2, K3 - initial, final value and a step change in the value K, respectively, may be represented by any arithmetic expressions; MOT, STER - Translation - "before", "step", the loop - any language BASIC operators; NEXT - operator (translated "next").
Teamwork operators and the scheme is determined by:
















where
?K 0
? =
K> K2, if K3 <0>

In other words, the operators of FOR and NEXT for changing values of K from K1 to K2 and K3 with the step execution statement (s) between FOR and NEXT, for each value of K.

Limitations:
1. Change the values of K1, K2, K3 in the implementation of FOR and NEXT statements are not recommended.
2. The loop, bypassing the operator of FOR, in BASIC prohibited.

Examples of solving

Example 1. Bring on the screen in a column are integers from 1 to 10.
CLS
FOR J = 1 TO 10 STEP 1
PRINT J
NEXT J
END

Example 2. Calculate the sum of integers from 1 to 10
CLS: S = 0
FOR I = 1 TO 10 STEP 1
S = S + I
NEXT I
PRINT ""; S
END

Example 3. Calculate the value of the function y = 2X2-3X +5 in the interval (-3, 3) with a step 1,5
CLS: PRINT "Y"; "X"
FOR X =- 3 TO 3 STEP 1.5
Y = 2 * X ^ 2-3 * X +5
PRINT Y, X
NEXT X
END

Example 4. Calculate the sum S = 2 +4 +...+ 2 N, where N is entered from the keyboard CLS: S = 0
INPUT ?type? N ?; N
FOR I = 1 TO N
S = S + 2 * N
NEXT I
PRINT ?sum =?; S
END

Example 5: Remove the word ?IBM? 10 times to get a diagonal
CLS
FOR K = 5 TO 15
LOCATE K, K
PRINT ?IBM?
NEXT K
END

Cycle WHILE ... WEND (POKA. .. END)

Construction WHILE ... WEND (POKA. .. END) enables teams to block until the value of expression, given in a WHILE - "The Truth".
General view of the operator

WHILE Boolean expression
- Block of commands -
WEND
Job operators can be determined by the following scheme:





NO



YES





After the cycle control is transferred to the team following the WEND.
If the verification conditions it appears that the value of a logical expression - "Lies", a block of commands will not be executed even once.
Using WHILE ... WEND can organize nested loops - each with its own WHILE ... WEND.
Limitation: in this design can not go out "prematurely", ie to the completion of the operator.
Examples of solving problems.
CLS: I = 1
WHILE I <5>
PRINT "I ="; I;
I = I +1
WEND
The screen will be: I = 1 I = 2 I = 3 I = 4

Tasks on "conditional operator" and "operator loop"

1.Nayti largest of the numbers (x + y) / 2 and (x + y / 2) for any numbers x and y.
2. Calculate the function values for any X and Z
a) Y = (X-15) / (x-6), b) Y = 2X-5 / (7Z-4X);

?X2 +5 X-14, if X
a) Y =
?3X2-7X, if X> =- 2
g) 5X2 +4 X-21, if X <-7>
Y =
?2X2-3X, where X> =- 7
d) X + Z, if X5
Y = X * Z in the other cases
3. Specifies the length sides of the triangle - A, B, C, to determine whether the triangle is isosceles.
4. Write a program that displays the first ten natural numbers.
5. Write a program that prints a table of squares of the first ten integers in the center of a blank screen.
6. Calculate the values of
a) Y = 5 * X2-4X +11 on the interval (-5,5) with a step 1,5;

b) X2-2 * X +3, where X
?Y =
X-18 +12, if X> = 0
a) SIN (X), if X
Y = on the interval (-6, 6) with a step 0,5.

7. Bring in a column a number of natural numbers from 1 to 10.

8. Display the column in even numbers from 1 to 20.

9. Display the line in the odd numbers from 15 to 20.

10. Search:
a) the sum of integers from 10 to 20;
b) the product of integers from 20 to 20;
c) the sum of odd numbers from 20 to 40;
d) the product of integers from 20 to 40;
d) the amount of even numbers from 1 to 20;
e) the product of even numbers from 1 to 20.

11. Bring on the screen 10 times the word "PENTIUM" diagonally.

12. DNA sequence of numbers entered from the keyboard. Find the sum of negative terms of this sequence and the product of positive, the number of negative and positive.

13. Make a program that displays:

a) motion "*" on the first line of the screen;
b) motion "*" on the last column of the screen;
a) motion "*" on the diagonal.

14. Calculate the amount, if N is entered from the keyboard:
a) 1 1 1 b) 1 1 1
15 + 25 + ... + N5; (3) 2 + (5) 2 + ... + (2N +1) 2;

15. Calculate the work, if A and B are entered from the keyboard:
a) 1 1 1;
(1 +12) * (1 +22 )...( 1 + N2)
b) A * (AN) * (A-2N )...( AN * N); c) 2 * 4 * 6 *...* 2 * N.

16. To determine whether an arbitrary number of multiples:
a) two b) three c) five.
17. Display the primes in the range
a) from 1 to 20, b) from 20 to 100.
18. Define an arbitrary number of simple.

String variables

In the language BASIC is possible to process not only numerical, but the text, the character data. To do this, use the character (or string, literal), constants, variables and expressions.
A character constant - A string of characters enclosed in quotation marks. The constant is the sequence of its constituent characters excluding quotes. Two consecutive quotation marks define an empty character string, not containing a single character.
In a character variable is a name that ends with the sign $, and meaning in a character string.
For strings, the comparison operation is: strings are considered equal if their lengths are equal and codes of all characters in pairs match. If one of the lines coincides with the beginning of another (but shorter than her), then it is less. In other cases, all decided to code the first dissenting character - less than the one line, where he had less.
Operations carried out on string variables
a) assignment of textual constants:
A $ = "A string of characters"
T $ = "" - clean lines
b) print the values of string variables:
PRINT A $, T $

c) gluing two lines:
T $ = A $ + B $
P $ = "WORD:" + P $
C $ = "pasting" + "" + "string"
d) a value of string variables from the keyboard:
INPUT A $, B $
- Input string can not conclude in the cavalryychki.

Basic functions work with character variables:

VAL (A $) - translate string to a number;
CHR $ (L) - gives the symbol of the code given number;
ASC (S $) - gives the first character string
SRT $ (K) - converts a number to a character string, which is recorded as a sequence of decimal digits;
LEN (F $) - gives the length of character expression;
LEFT $ (F $, N) - removes a specified number of characters on the left;
RIGHT $ (F $, N) - removes a specified number of characters to the right;
MID $ (F $, N1, N2) - clipping from the line specified number of characters with a character

Examples of solving problems.

Example 1. Calculate how many times among the characters given line meets the letter "F".
CLS
INPUT "Enter a string -"; S $
K = 0
FOR I = 1 TO LEN (S $)
IF MID $ (S $, I, 1) = "F" THEN K = K +1
NEXT I
PRINT "The letter F met"; K; "time (s)"
END

Example 2. Write a program that prints a given word backwards.
CLS
INPUT "Enter a word -"; S $
FOR I = LEN (S $) TO 1 STEP -1
PRINT MID $ (S $, I, 1);
NEXT I
END

Example 3. Issue position number given line, which first meets the letter "a". If such a letter in the line does, to give a message about this.
CLS: INPUT "Enter a string -"; S $
K = 0
FOR I = 1 TO LEN (S $)
IF MID $ (S $, I, 1) = "a" THEN 80
NEXT I
PRINT "The letters in there in a given string"
GOTO 90
80 PRINT "The first letter in the met in"; I; "-th position"
90 END

Tasks to work on character variables

1. Calculate how many times among the characters given line meets the letter ?F?.
2. Write a program that prints a given word backwards.
3. Calculate the number of digits in a given string.
4. Calculate the number of syllables in a word.
5. Check whether a given word palindrome ( "inverted", as the words KAZAK, shed, etc.)
6. Among the positive integers from 1 to n to find all such records which coincides with the last digit of their record-squares (5 and 25, 6 and 36, 25 and 625, etc.)
7. Issue position number given line, which first meets the letter "a". If such a letter in the line does, to give a message about this.
8. Issue position number given line, in which the fifth time met the letter ?W?. If this position is, to give a message about this.
9. In another string to calculate separately the number of characters "a" and ?b?.
10. From the given string to get a new one, replacing all the commas in point. Print the resulting string.
11. From the given string to get a new, emissions from the point of it all. Print the resulting string.
12. From the given string to get a new, deleting all asterisks (?*?) and repeating every character is different from the stars. Print received. line.
13. From the given string to get a new one, replacing it everything after the first star (?*?) sign "-" (if this line does not star, leave it unchanged). Print the resulting string.
14. From the given string to get a new one, remove all colon preceding the first point, and replacing it all the signs "+" after the first sign? -? (If this line does not point, add one at the end). Print the resulting string.
15. In another string to swap the first letter? eh? and the first letter? b?. If at least one of them there, print the message, or print the resulting string.
16. Determine the smallest word length in a given line (assume that the words are separated by spaces).
17. From the given string to provide string length of 5 characters (or until the end of the line, if you have less than), which begins with the first encountered in the line of letters? f?. Print this string or a message that it does not exist.
18. In a given line of the first symbol-Latin capital. If it? K ',? O?,? D?, Replace it with the corresponding lowercase letter. Print the resulting string.
19. In another string to count the number of letters of the Latin alphabet.
20. From the given string to get a new, deleting all the characters that are not in the Latin alphabet.
21. In another string to convert all uppercase letters of the Latin alphabet in lowercase, and lowercase to uppercase.
22. From the given string to get a new, deleting all the groups of letters? abcd?.
23. From the given string to get a new, seeing all the groups of letters? abc? on? abcd?.
24. Calculate how many words in the given string ends with the letter? I?, knowing that after the word is certainly worth a space or a point.
25. Given a positive integer n, the symbols s1, ... sn. Convert the sequence s1, ... sn,, replacing it:
a) all exclamation points;
b) each point of the ellipsis (ie three points);
a) each of the groups standing near the points of one point;
d) each of the groups standing near ellipsis points (ie three points).
26. Given a positive integer n, the symbols s1, ... sn. Determine whether the sequence s1, ... sn are members of the sequence sj, sj +1, that sj - a comma, and sj +1 - dash.
27. Given a positive integer n, the symbols s1, ... sn. Get the first integer j, for which each of the characters sj and sj +1 coincides with a letter. If such a pair of characters in the sequence of s1, ... sn no, the answer should be the number 0.

Arrays

In mathematics, the nature of the adoption of similar magnitude denoted by one common name, and distinguish them from the index. For example, members of a sequence can be described as follows:
?A1, A2 ,...., A n
name index
Similarly, coming in BASIC
?A (1) A (2) ... A (N)

name of the array index in parentheses
Array - a set of variables indicated by the common name and distinct with the indices, which are written in parentheses after the array name.
DIM English word (dimenshn) means an array
DIM statement is used to indicate the total number of variables in the array. It is necessary for rational allocation of computer memory.

Ad array
DIM A (7) the number of variables in the array (elements
?in the array)
Common name of the operator performance DIM is
array that is formed in memory
array of variables.
A (0) A (1) A (2) A (3) A (4) A (5) A (6) A (7)
A

Limitation: can not declare an array twice, so you should declare arrays in elementary strings program and not to return to these lines with the help of the operator GOTO.
Each array element has:
1) the name of X (5)
2) the index of place in the memory reserved
3) value of 3.2 for this element of the array

Enter the array elements can be done in several ways:
1) DIM A (5)
A (0) = 4: A (I) =- 2.5: (3) = 10: A (4) = 0: A (5) = 6: A (2) = 3
This input method is useful when an array of small
2) Enter the array elements with the keyboard
DIM A (9)
FOR I = 0 TO 9
INPUT A (I)
NEXT I
3) DIM B (6)
DATA 0, -2, 1, 5, 8, 5, 6. 26
FOR N = 0 TO 6
READ B (N)
NEXT N
Output array elements can be carried out in a row and a column:
1) DIM A (3)
PRINT A (0), A (I), A (2), A (3)
This method is suitable output, when an array of small
2) DIM A (10)
FOR I = 0 TO 9
PRINT A (I)
NEXT I

The basic techniques for solving problems using arrays

Example 1. Dan array of 10 elements. Find the sum of the array
DIM A (9)
S = 0
FOR N = 0 TO 9
S = S + A (N)
NEXT N
PRINT? Amount =?; S

Example 2. Find the minimal element of the array and the index of the minimum element
DIM L (9)
MIN = L (0): K = 0
FOR I = 1 TO 9
IF MIN> L (I) THEN MIN = L (I): K = I
NEXT I
PRINT? Least?; MIN

Example 3. 2 Given the array A (9), B (9). Get an array, each element of which is equal to the sum of the corresponding data elements of arrays
DIM A (9), B (9), C (9)
FOR I = 0 TO 9
C (I) = A (I) + B (I): PRINT C (I)
NEXT I
Sorting an array Ascending
1 Method (method of the bubble) 2 WAY (sorting method DIM A (9) simple way).
CLS DIM A (9)
FOR i = 0 TO 9 PRINT "Enter the 10 items"
INPUT A (i) FOR i = 0 TO 9
NEXT i INPUT A (i)
FOR i = 0 TO 9 NEXT i
FOR y = 9 TO i STEP - 1 FOR i = 0 TO 9
IF A (y)> A (y-1) THEN GOTO 20 P = A (i): K = i
m = A (y) FOR y = i +1 TO 9
A (y) = A (y-1): A (y-1) = m IF A (y)> P THEN GOTO 50
20 NEXT y P = A (y): K = y
NEXT i 50 NEXT y
FOR i = 0 TO 9 A (K) = A (i): A (i) = P
PRINT A (i) NEXT i
NEXT i PRINT "Sorted elements"
FOR i = 0 TO 9
PRINT A (i)
NEXT i
END

3 way (method of simple inclusion)
DIM A (10), B (9)
PRINT "Enter the 10 items"
FOR i = 0 TO 9
INPUT B (i)
NEXT i
FOR i = 1 TO 10
A (i) = B (i-1)
NEXT i
FOR i = 1 TO 10
P = A (I): Y = I-1
40IF P0 THEN A (Y +1) = A (Y): Y = Y-1: GOTO 40
A (Y +1) = P
NEXT i
PRINT "Sorted elements"
FOR i = 1 TO 10
PRINT A (i)
NEXT i
END

Challenges for the use of the cycle when processing arrays.
1. Display the positive elements of the array X (k), then the negative elements of the array Y (m) and the number of retired numbers.
2. Given k and an array of X (k). Find the sum.
(X1-P) 2 + (X2-P) 2 +...+( Xk-P) 2, where P = X1 + X2 +...+ Hk) / k.
3. Given m and an array X (m). Find the product.
(2 + X21) * (2 + x22 )*...*( 2 + H2m).
4. Find the array element number X (k), closest to C, where
C = (X1 + X2 +...+ Hk) / k
5. Given P, m and an array of T (m). Find the number of elements in the array of T less than C, and for elements with large, find their average.
6. For the array of T (m) to find the number of elements, more than the previous element, but for those that have less to find their average.
7. Find the smallest number of positive elements of the array X (m).
8. For an array X (m) print sum and the product number of positive elements after the last zero element.
9. Given k and an array of T (k). Find the sum and the number of elements in the array of T after the first zero element.
10. Given m and an array A (m). Print the amount of negative elements of the array A after the first zero element.
11. Given m, the coordinates XA, UA point A and the array of 2m to the numbers coordinates X1, Y1, X2, Y2 ,..., Hm, Ym points B1, B2 ,..., Vm. Display the number and coordinates of points in the most remote from the point A.
12. Find the total number of zero elements in the array x (m), Y (k).
13. Establish and lead an array of T of nonnegative elements in the array X (m). Print the number of elements in the array T.
14. Display even meaningfully among the positive elements of the array X (m), starting with the first positive element.
15. Double the largest element of the array X (m) and print the modified array.
16. Display the nonzero elements of the array X (m) and their product.
17. Find the sum and the number of odd elements of an array by value X (m).
18. To establish an array of T of nonzero elements of the array X (m). Then bring an array of T and the number of elements in it.
19. In the array of T (m) to replace the zero elements of the greatest element.
20. In the array X (m) to find the amount and number of elements between the first and last zero elements.
21. Swap the largest and smallest elements of the array of T (m).
22. In the array X (m) to find the total number of elements to the first and after the last zero elements.
23. How many elements in the array X (m) after the second zero element.
24. Among the elements of array x (m) and Y (m) form an array
H (X1, Y1, X2, Y2 ,..., X (m), Y (m) of 2m elements.
25. Round the elements of the array X (m) to the nearest integer.
26. Among the elements of array x (m), Y (k) form an array
H ((X1, X2, X3 ,..., Hm, V1, V2, V3 ,..., Uk) of m + k elements.
27. Find number of the second zero element of the array X (m).
28. Find the penultimate number of the zero element of the array X (m).
29. Transpose array elements X (m) in reverse order, ie Hm ,..., X2, X1.
30. In the array X (m) to find the number of elements between the first and second zero elements.
31. How in the array of T (m) elements, less the sum of all elements?
32. In the array of T (m) zero elements replaced by the sum of all elements.
33. Of whether it constitutes an arithmetic or geometric progression elements of the array X (m)?
34. In the array of T (m) to replace the elements with even-numbered elements of the sum of the odd numbers.
35. Find the distance R between arrays A (k) and B (k) by the formula:
P2 (A1-B1) 2 + (A2-B2) 2 +...+( Ak-Bk) 2.
36. In the array R to record first negative elements of the array X (k). then positive.
37. In the array X (k) to find the sum of the elements and their number before the first sign change.
38. Among the elements of the array X (k), falling in the interval [A, B], to compile an array of M and take him.
39. On the xy-plane are given k points arrays coordinates X (k), Y (k). To establish an array of numbers of points outside the I quarter.
40. To establish an array of N numbers of zero elements of the array X (k).
41. In one-dimensional array with an even number of elements (2 * N) are the coordinates of N points in the plane. They are located in the following order: x1, y1, x2, y2, x3, y3, etc. Determine the minimum radius of the circle with center at the origin, which contains all the points, and the number of the most distant from each other points.
42. In the two-dimensional array of N x M contains M N ordinates of graphs of functions at points 1,2,3 ,..., M. To determine whether these graphs intersect at one point, and if so, find its number. Assume that the graphs can intersect only in specified locations.
43. In one-dimensional array contains a schedule elektroproezda from Perm to Kungur in the form:
first element, it moves to the first stop;
second element-time parking at the first stop;
third element, it moves to the second stop;
fourth element-time parking at the second stop;
and so on ....< br /> last item, it moves from the penultimate stop before Kungur.
44. In one-dimensional array stored the results of a sociological survey. Write a program to count the number of results that deviate from the average not more than 7%.
45. From the island of Buyan to the glorious kingdom Saltan month journey. Captain wrote in his logbook the number of miles covered per day. Write a program that determines which way desyatidnevku come a long way.
46. In the array data is stored on the ambient temperature for the month. Determine the coldest decade of the month.
47. The growth of two groups of students, in which respectively 23 and 25, located in two arrays. Required to determine the average height of students in each group, as well as the number of students in the two groups together, with growth above 180 cm
48. 20 store buyers appreciate the quality of product grades 3,4,5. Determine how much per cent of buyers have put 5,4 and 3, separately from the total number of buyers participating in the examination of goods.
49. In the competition involved teams of three classes of 6 people each. The results of each team entered in a particular array in the form of points, which the judges evaluated each participant. Determine the winning team.
50. To test 15 entrants for the distribution of the groups for the study of foreign languages: English, French, German, basic familiarity with a foreign language. Make a program that counts the number of entrants in each group, depending on how the applicant responded to the question of learning a foreign language in school.
51. During the month of January in the house was not working boiler, so the temperature in the apartment was unstable. Determine the number of days during which residents were fortunate to have a temperature not lower than 15 degrees, as well as to calculate the average air temperature in the apartments this month. To solve the problem using an array.
52. 18 students passed the standard for throwing grenades. Make a program that determines what percentage of students completed the norm. If you know that the rate of 38 meters.
53. In every sunny day a snail sitting on a tree, rises up to 2 cm, and in every dull day goes down to 1 cm in the early observations snail is 30 cm from the ground. Dan array of 30 elements, containing information about whether the day was sunny or cloudy. Make a program determining the location of the cochlea by the end of 30 days.
54. On the day of your birth aunt put your name in savings banks in the amount of 1000 rubles. Each year the contribution is added to S% per annum. Make a program to calculate:
a) how many years the contribution will reach R rubles?
b) what the contribution rate will be 15 years after the investment?

Operators graphics

Modern computers have excellent graphics capabilities - in modern multimedia computers can even view and edit the video. Graphics is focused on the construction of simple geometric shapes, and realization of the elementary features dynamic graphics.
In order to work with graphic information necessary to install the graphics mode of a special operator, and use the corresponding operators:

1. SCREEN N-operator is the inclusion of graphics mode, where N - number of modes (0 - a text mode, from 1 to 13 - graphic modes)

2. PSET (X, Y) - operator of drawing point with coordinates X, Y (0

More NEWS:
{related-news}