Programming. Basic algorithmic constructs

To create any programs you need basic algorithmic constructs. Following is the easiest way to solve problems. It can be used, for example, to work with similar examples. There are other types: branching and looping. They will be described in this article. But first you need to understand what constitutes the algorithm as a whole.

Algorithm

The word "algorithm" comes from the Latin algoritmi. What does it mean? The authentic word came from the name of a mathematician, whose activity fell on the 9th century. Thanks to the treatise of al-Khwarizmi, mankind was able to get acquainted with the main type of algorithmic construction and, in general, with the general concept.

Earlier, the spelling form of the word was adopted - "algorithm". Now it is used only in some cases.

– , , . , . , , . . , , , . . . .

, . ?

  1. . , .
  2. . , . , .
  3. . , , .

, . . , , .





, «». .

, , , . , . , - , . , .

?

  1. . . , , , , , , , .
  2. . ? . - . - , , . , .
  3. . - . .
  4. . . , , .
  5. . – . , .
  6. . , - , . , , . . , .

, :









  • . , , .
  • . , , , .
  • -. , .
  • . -.

. -? , . , . , -, . ().

basic algorithmic constructs




, 3 , 4. : , , . , . . .

  1. . , , . , . , . , . . .
    algorithm basic algorithmic constructs




  2. . ( ) ( «» «»). . , . , , – . . , . .
  3. . , , . , .

, (, , ) , .

?

  • . , , . . .
  • .
  • , , «» .

. . – , , .

the main type of algorithmic design is




, . ? , , . , , . (, , ) . , « » .

, . . ? . , , , , . , .

:

  1. .
  2. .
  3. .
  4. .
  5. .
  6. .
  7. .
  8. .

- , , .

does not apply to basic algorithmic constructs




, ? , . .

. .

, "", "", " ", " ", "", " ". , and () or ().

: ((+3)/1) , , – .

. .

– , , . . for.

4 :

  1. « ?»
  2. «, !»
  3. « ?»
  4. «, !»

. ? «» .

1. For i:=1 to 2 do:

- i , .

2. Begin ( , .)

3. Writeln (‘ ?’):

- writeln , .

4. Writeln (‘, ').

5. End.

6. i:=i + 1.

, . , .

basic algorithmic constructs linear branching cyclic




. . , . . . .

Repeat A until B. « , ». , , – , .

basic algorithmic constructs basic algorithms




, . , , . . . «while A do B». «». – , – , . : « , ».

. ? , , , , . , . , , .

basic algorithmic constructions repetition




The auxiliary algorithm is used in other processes by indicating only its name. It does not apply to the basic algorithmic constructions. In programming languages, this process is called a subroutine. To facilitate working with the code and subsequently easier task solving, each action is combined into one block, which is an auxiliary algorithm. Each of them can be given its own name, which subsequently allows you to repeatedly contact him.




All Articles