In schools, to study the basics of algorithmization, the so-called. school algorithmic language (educational algorithmic language), using words in Russian that are understandable to schoolchildren. Unlike most programming languages, an algorithmic language is not tied to computer architecture and does not contain details related to the design of the machine.

Examples

The algorithm in algorithmic language is generally written in the form:

alg name of the algorithm (arguments and results) given conditions for applicability of the algorithm necessary purpose of the algorithm beginning description of intermediate quantities | sequence of commands (body of the algorithm) con

In the algorithm record, keywords were usually underlined or in bold. To highlight logical blocks, indentations were used, and paired words of the beginning and end of the block were connected by a vertical bar.

An example of calculating the sum of squares:

alg Sum of squares ( arg intact n, res intact S) given| n > 0 necessary| S = 1*1 + 2*2 + 3*3 + … + n*n beginning intact i | input n; S:=0 | nc for i from 1 to n | | S:= S + i * i | kts | conclusion"S = ", S con

E-workshop

To support the theoretical study of programming in an algorithmic language, specialists from the Faculty of Mechanics and Mathematics of Moscow State University created an editor-compiler in 1985 "E-workshop"(“E” - in honor of Ershov), allowing you to enter, edit and execute programs in an algorithmic language.

In 1986, a set of educational worlds (performers) was released for the “E-workshop”: “Robot”, “Draftsman””, “Two-legged”, “All-terrain Vehicle”, which allow you to simply introduce the concepts of the algorithm. “E-workshop” was implemented on computers: Yamaha, Corvette, UKNC and became widespread.

This programming language was constantly being refined and a description of a later version of the “E-workshop” appeared in a textbook in 1990. The programming system "KuMir" ("Set of Educational Worlds"), which supports this textbook, was released by the InfoMir enterprise in 1990. The language of this system is also called “Idol”.

In 1995, “KuMir” was recommended by the Ministry of Education of the Russian Federation as the main educational material for the course “Fundamentals of Informatics and Computer Science” based on the textbook by A. G. Kushnirenko, G. V. Lebedev and R. A. Svoren. .

Criticism

However, it should be noted that the algorithmic language, in the absence of details connecting it directly with the computer architecture, nevertheless, referring to Algolo-like languages, implicitly teaches schoolchildren to rely on the von Neumann architecture of machines. (Von Neumann architecture is practical implementation an earlier idea called the Turing Machine. Besides Turing's idea, there are other ideas. The most popular of them is called Lambda calculus: Alonzo Church worked on it. A Lisp machine is an architecture that is based on Lambda calculus.)

Links

  • A. P. Ershov. Algorithmic language in the school course on the fundamentals of computer science and computer technology. 05/07/1985
  • Forum on Russian programming languages ​​and development tools

Wikimedia Foundation. 2010.

See what “Russian algorithmic language” is in other dictionaries:

    Algorithmic language is a formal language used to write, implement, or study algorithms. Every programming language is an algorithmic language, but not every algorithmic language is suitable for use as a language... ... Wikipedia

    This term has other meanings, see Dragon (meanings). An example of a block diagram of an algorithm in the DRAGON language dragon diagram DRAGON (Friendly Russian Algorithmic Language That Provides Visibility) visual... ... Wikipedia

    This term has other meanings, see Algorithmic language. Academic algorithmic language is a formal language used to write, implement, and study algorithms. Unlike most programming languages, it is not tied to ... Wikipedia

    Algorithmic language (also Russian algorithmic language, RAYA) is a programming language used for writing and studying algorithms. When studying computer science in schools, the so-called algorithm is used to study the basics of algorithmization. school algorithmic... ... Wikipedia

    Educational programming language is a programming language designed to teach programming to specialists. Such a language must meet the main requirement: simplicity. The simpler it is, the faster a beginner will master it. The possibilities of such... ... Wikipedia

    An example of a block diagram of an algorithm in the DRAGON language dragon diagram DRAGON (Friendly Russian Algorithmic Language That Provides Visibility) is a visual algorithmic language created as part of the Buran space program. Development of this language ... Wikipedia

An algorithm is an accurate and understandable instruction for the performer to perform a sequence of actions aimed at solving a given problem.

The name "algorithm" comes from the Latin form of the name of the Central Asian mathematician al-Khwarizmi - Algorithmi. Algorithm is one of the basic concepts of computer science and mathematics.

An algorithm executor is some abstract or real (technical, biological or biotechnical) system capable of performing the actions prescribed by the algorithm.

The performer is characterized by:

elementary actions;

command system;

The environment (or setting) is the “habitat” of the performer. For example, for the performer Robot from the school textbook, the environment is an infinite cellular field. Walls and painted cells are also part of the environment. And their location and the position of the Robot itself determine the specific state of the environment.

Each executor can execute commands only from a certain strictly defined list - the system of executor commands. For each command, the conditions of applicability must be specified (in which environmental states the command can be executed) and the results of executing the command must be described. For example, the Work command “up” can be executed if there is no wall above the Work. Its result is the displacement of the Robot one cell up.

After calling the command, the performer performs the corresponding elementary action.

Executor failures occur if a command is called in an environment state that is unacceptable for it.

Usually the performer knows nothing about the purpose of the algorithm. He carries out all the commands he receives without asking why or why.

In computer science, the universal executor of algorithms is the computer.

The main properties of the algorithms are as follows:

Understandability for the performer - i.e. The executor of the algorithm must know how to execute it.

Discreteness (discontinuity, separateness) - i.e. The algorithm must represent the process of solving a problem as a sequential execution of simple (or previously defined) steps (stages).

Certainty - i.e. Each rule of the algorithm must be clear, unambiguous and leave no room for arbitrariness. Thanks to this property, the execution of the algorithm is mechanical in nature and does not require any additional instructions or information about the problem being solved.

Effectiveness (or finitude). This property is that the algorithm must lead to solving the problem in a finite number of steps.

Mass character. This means that the algorithm for solving the problem is developed in a general form, i.e. it should be applicable to a certain class of problems that differ only in the initial data. In this case, the initial data can be selected from a certain area, which is called the area of ​​applicability of the algorithm.

In practice, the most common forms of presenting algorithms are:

verbal (recordings in natural language);

graphic (images from graphic symbols);

pseudocodes (semi-formalized descriptions of algorithms in a conventional algorithmic language, including both elements of a programming language and natural language phrases, generally accepted mathematical notations, etc.);

software (texts in programming languages).

The verbal way of writing algorithms is a description of the successive stages of data processing. The algorithm is specified in a free form in natural language.

For example. Write down an algorithm for finding the greatest common divisor (GCD) of two natural numbers.

The algorithm could be as follows:

set two numbers;

if the numbers are equal, then take any of them as the answer and stop, otherwise continue executing the algorithm;

determine the largest of the numbers;

replace the larger number with the difference between the larger and smaller numbers;

repeat the algorithm from step 2.

The described algorithm is applicable to any natural numbers and should lead to a solution to the problem. Convince yourself of this by using this algorithm to determine the greatest common divisor of the numbers 125 and 75.

The verbal method is not widespread for the following reasons:

such descriptions are not strictly formalized;

suffer from verbosity of entries;

allow for ambiguity in the interpretation of individual instructions.

The graphical way of presenting algorithms is more compact and visual compared to the verbal one.

When presented graphically, the algorithm is depicted as a sequence of interconnected functional blocks, each of which corresponds to the execution of one or more actions.

This graphical representation is called a flowchart or flowchart.

In the flowchart, each type of action (entering initial data, calculating the values ​​of expressions, checking conditions, controlling the repetition of actions, completing processing, etc.) corresponds to a geometric figure represented as a block symbol. Block symbols are connected by transition lines that determine the order in which actions are performed.

Table 1 shows the most commonly used symbols.

The "process" block is used to denote an action or sequence of actions that changes the value, form of presentation or placement of data. To improve the clarity of the diagram, several individual processing blocks can be combined into one block. The presentation of individual operations is quite free.

The "decision" block is used to indicate conditional control transitions. Each "solution" block must identify the question, condition, or comparison it defines.

The "modification" block is used to organize cyclic structures. (The word modification means modification, transformation). A cycle parameter is written inside the block, for which its initial value, boundary condition and step of changing the parameter value are indicated for each repetition.

The "predefined process" block is used to indicate calls to auxiliary algorithms that exist autonomously in the form of some independent modules, and for calls to library routines.

Pseudocode is a system of notations and rules designed to uniformly write algorithms.

It occupies an intermediate place between natural and formal languages.

On the one hand, it is close to ordinary natural language, so algorithms can be written and read in it like regular text. On the other hand, pseudocode uses some formal constructs and mathematical symbolism, which brings the algorithm notation closer to the generally accepted mathematical notation.

In pseudocode, strict syntactic rules for writing commands inherent in formal languages ​​are not adopted, which makes it easier to write the algorithm at the design stage and makes it possible to use a wider set of commands designed for an abstract executor. However, pseudocode usually contains some constructs that are inherent in formal languages, which makes it easier to move from writing in pseudocode to writing an algorithm in a formal language. In particular, in pseudocode, as well as in formal languages, there are function words, the meaning of which is determined once and for all. They appear in bold in printed text and are underlined in handwritten text. There is no single or formal definition of pseudocode, so various pseudocodes are possible, differing in the set of function words and basic (basic) constructions.

An example of pseudocode is the school algorithmic language in Russian notation (school AYA), described in the textbook by A.G. Kushnirenko et al. “Fundamentals of Informatics and Computer Science”, 1991. In the future we will simply call this language “algorithmic language”.

Basic function words

General view of the algorithm:

alg name of the algorithm (arguments and results)

conditions for the applicability of the algorithm are given

you need the goal of executing the algorithm

initial description of intermediate quantities

| sequence of commands (body of the algorithm)

The part of the algorithm from the word alg to the word beg is called the header, and the part contained between the words beg and end is the body of the algorithm.

In the sentence alg after the name of the algorithm in parentheses the characteristics (arg, res) and value type (integer, thing, sim, lit or log) of all input (arguments) and output (results) variables are indicated. When describing arrays (tables), the service word tab is used, supplemented by boundary pairs for each index of the array elements.

Example sentences alg:

alg Volume and area of ​​the cylinder (arg things R, H, res things V, S)

alg Roots KvUr(arg things a, b, c, res things x1, x2, res lit t)

alg Exclude element(arg int N, arg res stuff tab A)

alg Diagonal(arg int N, arg int tab A, res lit Answer)

Suggestions given and must are not binding. It is recommended to write down statements describing the state of the environment of the algorithm executor, for example:

alg Replacement (arg lit Str1, Str2, arg res lit Text)

given | the lengths of the substrings Str1 and Str2 are the same

need | Everywhere in the Text line, the substring Str1 is replaced by Str2

alg Number of maxima (arg int N, arg thing tab A, res int K)

given | N>0

need | K - the number of maximum elements in table A

alg Resistance (args things R1, R2, args int N, res things R)

given | N>5, R1>0, R2>0

need | R - circuit resistance

Here in sentences given and necessary after the sign "|" comments recorded. Comments can be placed at the end of any line. They are not processed by the translator, but make the algorithm much easier to understand.

Algorithms can be thought of as certain structures consisting of individual basic (i.e. basic) elements.

Naturally, with this approach to algorithms, the study of the basic principles of their design should begin with the study of these basic elements.

To describe them we will use the language of algorithm diagrams and school algorithmic language.

The logical structure of any algorithm can be represented by a combination of three basic structures:

following,

branching,

A characteristic feature of basic structures is the presence of one input and one output.



Algorithm. School algorithmic language.

Algorithm - an accurate and understandable instruction to the performer to perform a sequence of actions aimed at solving the task.

  • The name "algorithm" comes from the Latin form of the name of the Central Asian mathematician al-Khwarizmi - Algorithmi. Algorithm is one of the basic concepts of computer science and mathematics.


Algorithm executor - this is some abstract or real (technical, biological or biotechnical) system capable of performing actions prescribed by the algorithm.

  • The performer is characterized by:

  • Wednesday;

  • elementary actions;

  • command system;

  • refusals.

  • Wednesday(or setting) is the “habitat” of the performer.

  • Command system. Each executor can execute commands only from a certain strictly defined list - the system of executor commands. For each command, the conditions of applicability must be specified (in which environmental states the command can be executed) and the results of executing the command must be described.

  • After calling the command, the performer performs the corresponding elementary action.

  • Failures executor errors occur if a command is called when the environment state is unacceptable for it.


The main properties of the algorithms are as follows:

  • Understandability for the performer - i.e. The executor of the algorithm must know how to execute it.

  • Discreteness(discontinuity, separateness) - i.e. the algorithm must represent the process of solving a problem as a sequential execution of simple (or previously defined) steps (stages).

  • Certainty- i.e. Each rule of the algorithm must be clear, unambiguous and leave no room for arbitrariness. Thanks to this property, the execution of the algorithm is mechanical in nature and does not require any additional instructions or information about the problem being solved.

  • Efficiency(or limb). This property is that the algorithm must lead to a solution to the problem in a finite number of steps.

  • Mass character. This means that the algorithm for solving the problem is developed in a general form, i.e. it should be applicable for a certain class of problems that differ only in the initial data. In this case, the initial data can be selected from a certain area, which is called the area of ​​applicability of the algorithm.


Forms of presentation of algorithms:

  • verbal (recordings in natural language);

  • graphic (images from graphic symbols);

  • pseudocodes (semi-formalized descriptions of algorithms in a conventional algorithmic language, including both elements of a programming language and natural language phrases, generally accepted mathematical notations, etc.);

  • software (texts in programming languages).


Verbal method Algorithm records are a description of the successive stages of data processing. The algorithm is specified in a free form in natural language.

  • For example. Write down the finding algorithm greatest common divisor (GCD) two natural numbers. The algorithm could be as follows:

  • set two numbers;

  • if the numbers are equal, then take any of them as the answer and stop, otherwise continue executing the algorithm;

  • determine the largest of the numbers;

  • replace the larger number with the difference between the larger and smaller numbers;

  • repeat the algorithm from step 2.


When presented graphically, the algorithm is depicted as a sequence of interconnected functional blocks, each of which corresponds to the execution of one or more actions.

  • This graphical representation is called a flowchart or block diagram.


Pseudocode is a system of notation and rules designed for uniform recording of algorithms.

    In pseudocode, strict syntactic rules for writing commands inherent in formal languages ​​are not adopted, which makes it easier to write the algorithm at the design stage and makes it possible to use a wider set of commands designed for an abstract executor. However, pseudocode usually contains some constructs that are inherent in formal languages, which makes it easier to move from writing in pseudocode to writing an algorithm in a formal language. In particular, in pseudocode, as well as in formal languages, there are function words, the meaning of which is determined once and for all. They appear in bold in printed text and are underlined in handwritten text. There is no single or formal definition of pseudocode, so various pseudocodes are possible, differing in the set of function words and basic (basic) constructions.

  • An example of pseudocode is the school algorithmic language in Russian notation (school AYA),


Basic function words


General view of the algorithm:

  • alg name of the algorithm (arguments and results)

  • given conditions for applicability of the algorithm

  • necessary purpose of the algorithm

  • beginning description of intermediate quantities

  • sequence of commands (body

  • algorithm)


Part of the algorithm from the word alg to the word beginning called title beginning And con - body algorithm.

  • Part of the algorithm from the word alg to the word beginning called title , and the part between the words beginning And con - body algorithm.

  • In a sentence alg after the name of the algorithm in parentheses indicate characteristics (arg, res) And value type (int, thing, sim, lit or log) everyone input (arguments) And weekend (results) variables. When describing arrays (tables), a special word is used tab, supplemented boundary pairs at each index of the array elements.


School AY teams

  • Assignment operator. Used to evaluate expressions and assign their values ​​to variables. General view: A:= B, where the ":=" sign means the command replace the previous value of the variable on the left side, to the calculated value of the expression on the right side.

  • For example, a:=(b+c)*sin(Pi/4); i:=i+1.

  • For data input and output use commands

  • input variable names

  • conclusion variable names, expressions, texts.

  • For branching apply commands If And choice, For organizing cycles - commands For And Bye


An example of writing an algorithm in school AY

  • alg Sum of squares ( arg int n, cut intact S)

  • given| n > 0

  • necessary| S = 1*1 + 2*2 + 3*3 + ... + n*n

  • start intact i

  • input n; S:=0

  • nc for i from 1 to n S:=S+i*i

  • conclusion"S = ", S


Algorithms can be represented as certain structures consisting of individual basic (i.e. main) elements.

  • 1. Basic structure following .


2. Basic structure branching .

  • Structure branching exists in four main variants:

  • if-then;

  • if-otherwise;

  • choice;

  • choice-otherwise.


2. Basic structure branching .


2. Basic structure branching .


3. Basic structure cycle.

  • Provides multiple execution some set of actions called body of the loop.


What concepts do algorithmic languages ​​use?

  • Language concept determined in interaction syntactic and semantic rules Syntactic rules show how a given concept is formed from other concepts and letters of the alphabet, and semantic rules determine the properties of a given concept


The basic concepts in algorithmic languages ​​are usually the following.

  • Names (identifiers) - used to denote program objects(variables, arrays, functions, etc.).

  • Operations . Types of operations:

  • arithmetic operations + , - , * , / etc. ;

  • logical operations and, or, not;

  • operations relationship , = , = , ;

  • operation couplings(otherwise, “attachments”, “concatenations”) of character values ​​with each other to form one long string; is represented by a "+" sign.

  • Data - quantities processed by the program. There are three main types of data: constants, variables and arrays.

  • Constants- this is data that is recorded in the text of the program and does not change during its execution.

  • Examples of constants:

    • numeric 7.5, 12;
    • logical Yes(true) , No(lie);
    • symbolic"A", "+";
    • lettered"abcde", "computer science", "" (empty string).
  • Variables are designated by names and can change their values ​​during program execution. There are variables integer, real, logical, character and literal.

  • Arrays are sequences of elements of the same type, the number of which is fixed and assigned the same name. The position of an element in an array is uniquely determined by its indices (one, in the case of a one-dimensional array, or several, if the array is multidimensional). Sometimes arrays are called tables.


Expressions

  • Expressions - are intended to perform the necessary calculations, consist of constants, variables, function pointers (for example, exp(x)), united by operation signs.

  • Expressions are written in the form linear sequences of characters(without subscript and superscript symbols, “multi-story” fractions, etc.), which allows you to enter them into the computer by sequentially pressing the corresponding keyboard keys.

  • There are expressions arithmetic, logical and string.

  • Arithmetic expressions are used to determine a single numeric value. For example, (1+sin(x))/2. The value of this expression at x=0 is 0.5, and at x=p/2 it is one.

  • Logical expressions describe certain conditions that may or may not be satisfied. So a Boolean expression can only take two values ​​- "true" or " lie" (Yes or No). Let's consider as an example the logical expression x*x + y*y "true", and for x=2, y=2, r=1 - "lie".

  • Values ​​of string (literal) expressions - texts. They can include literal constants, literal variables, and literal functions separated by a concatenation operator. For example, A + B means appending string B to the end of string A. If A = "bush", and B = "green", then the value of the expression A+B is " green bush".

  • Operators (teams). An operator is the largest and most meaningful concept of a language: each operator is a complete phrase of the language and defines some completely completed stage of data processing. The operators include:

  • keywords;

  • data;

  • expressions, etc.

  • Operators are divided into executable and non-executable. Non-executable statements are intended to describe data and program structure, and executable- to perform various actions (for example, assignment operator, input and output operators, conditional operator, loop operators, procedure operator, etc.).


Frequently used functions are calculated using subroutines called standard features, which are pre-programmed and built into the language translator.


Table of standard functions of school algorithmic language


  • You can use constants, variables, and expressions as function arguments. For example: sin(3.05) min(a, 5)

  • sin(x) min(a, b)

  • sin(2*y+t/2) min(a+b, a*b)

  • sin((exp(x)+1)**2)

  • min(min(a,b),

  • min(c,d))


Arithmetic expressions are written according to the following rules:

  • You cannot omit the multiplication sign between factors and put two operation signs next to each other.

  • Indexes of array elements are written in square (school AYA, Pascal) or round (Basic) brackets.

  • Letters of the Latin alphabet are used to designate variables.

  • Operations are performed in order of precedence: first calculate functions, then raise to powers, then multiply and divide, and lastly add and subtract.

  • Operations of the same precedence are performed from left to right. For example, a/b*c matches a/b*c. However, in school AY there is one thing exception from this rule: exponentiation operations are performed from right to left. So, the expression 2**(3**2) in school AY is calculated as 2**(3**2) = 512. In the QBasic language, a similar expression 2^3^2 is calculated as (2^3)^2 = 64. And in the language Pascal There is no operation of exponentiation at all; in Pascal x^y is written as exp(y*ln(x)), and x^y^z as exp(exp(z*ln(y))*ln(x)).


Examples of writing arithmetic expressions


Typical errors in writing expressions:

  • a+sin x

  • (a+b)/c**3



Examples of writing logical expressions that are true when the specified conditions are met.


Write down the expressions according to the rules of the algorithmic language:


  • a+b/c+1;

  • a**b**c/2;

  • a/b/c/d*p*q;

  • 4/3*3.14*r**3;

  • d*c/2/R+a**3;


An educational algorithmic language is a means for writing algorithms in a form intermediate between writing an algorithm in natural (human) language and writing it in a computer language (programming language).

The advantages of the educational algorithmic language include its simplicity, as well as the fact that the algorithm is written in Russian using a certain limited number of words, the meaning and method of use of which are strictly defined. These words are called function words.

In order to distinguish function words from other words of the language, they are underlined when writing.

An algorithm record in a training algorithmic language consists of a header and a body of the algorithm. The body of the algorithm is contained between the keywords beginning And con and is a sequence of algorithm commands. The header includes the name of the algorithm, reflecting its content, lists of initial data (arguments) and results.

The algorithm header sign is keyword alg.

So, the algorithm, written in educational algorithmic language, has the following form:

alg name of the algorithm

arg list of source data

res list of results

sequence of algorithm commands

It is advisable to start learning the school algorithmic language with the assignment command; it is one of the main commands.

It is written like this:

<переменная> := <выражение>

The sign ": =" reads "assign".

In the case where the value to which the value is assigned is included in the right side of the command, the following happens:

1) the value of the expression written on the right side of the assignment command is calculated using the current values ​​of all quantities included in this expression;

2) the variable is assigned a new calculated current value. In this case, the previous value of the variable is destroyed.

Therefore, the command b: = a + b means that the value of variable a is added to the previous current value of b and the resulting result becomes the new current value of b.

This example illustrates three basic properties of assignment:

1) until a variable is assigned a value, it remains undefined;

2) the value assigned to a variable is stored in it until the next assignment of a new value to this variable;

3) a new value assigned to a variable replaces its previous value.

Now let's get acquainted with the basic structures, starting with such an operation as “following”. It is formed by a sequence of actions following one after another:

action 1

action 2

. . . . . . . . .

action n

Next we'll look at the basic branching structure. It ensures, depending on the result of checking the condition (yes or no), the choice of one of the alternative ways of operating the algorithm. Each path leads to a common output, so the algorithm will continue to run no matter which path is chosen. The branching structure comes in four main variations:



1. if something;

If condition

That actions

2. if-else;

If condition

That actions 1

otherwise actions 2

choice

atcondition 1: actions 1

atcondition 2: actions 2

. . . . . . . . . . . .

at condition N: actions N

{otherwiseactions N+1}

And finally, the basic structure of the cycle using the school algorithmic language will look like this.

Recording an algorithm in an algorithmic (formal) language is called a program. Sometimes the very concept of an algorithm is identified with its notation, so that the words “algorithm” and “program” are almost synonymous. A small difference is that when mentioning an algorithm, they usually mean the basic idea of ​​its construction, which is common to all algorithmic languages. A program is always associated with writing an algorithm in a specific formal language.

When presenting the idea of ​​an algorithm, for example, when publishing in scientific article, it is not always advisable to use any specific programming language, so as not to clutter the presentation with unimportant details. In such cases informal algorithmic language is used, as close to natural as possible. This type of language is called pseudocode. It is not difficult for a specialist to rewrite a program from pseudocode into any specific programming language. Writing an algorithm in pseudocode is often clearer and more visual; it allows you to freely choose the level of detail, from a description in very general terms to a detailed presentation.

Pseudocodes are semi-formalized descriptions of algorithms based on conditional algorithmic language, including both elements of a programming language and natural language phrases, generally accepted mathematical notations, and more.

Pseudocode is a system of notations and rules designed to uniformly write algorithms.

Pseudocode occupies an intermediate place between natural language and programming languages. On the one hand, it is close to ordinary, natural language, so algorithms can be written and read in it like regular text. On the other hand, pseudocode uses some formal constructs and mathematical symbolism, which brings the algorithm notation closer to the generally accepted mathematical notation.

Pseudocode usually contains some constructs that are native to programming languages. This facilitates the transition from writing in pseudocode to writing the algorithm in a programming language for a specific computer. In particular, in pseudocode, as well as in programming languages, there are function words, the meaning of which is determined once and for all. They appear in bold in printed text and are underlined in handwritten text.

General view of the algorithm:

alg name of the algorithm (arguments and results)

given conditions for applicability of the algorithm

necessary purpose of the algorithm

beginning description of intermediate quantities

sequence of commands(algorithm body)

Part of the algorithm from the word alg to the word beginning is called the heading, and the part between the words beginning And con - body of the algorithm.

In a sentence alg after the name of the algorithm, the characteristics (arg, res) and value type (integer, thing, sim, lit or log) of all input (arguments) and output (results) variables are indicated in parentheses. When describing arrays (tables), a special word is used tab, supplemented by boundary pairs at each array element index.

Example sentences alg :

alg Volume and area of ​​the cylinder (arg things R, H, res things V, S)

alg Roots KvUr ( arg thing a, b, c, res things x1, x2, res lit t)

alg Exclude element ( arg integer N, arg res things tab A)

alg Diagonal ( arg integer N, arg whole tab A, res lit Answer)

Offers given And necessary not required. It is recommended to write down statements describing the state of the environment of the algorithm executor, for example:

alg Replacement (arg lit Str1, Str2, arg res lit Text)

given | the lengths of the substrings Str1 and Str2 are the same

need | Everywhere in the Text line, the substring Str1 is replaced by Str2

alg Number of maxima (arg int N, arg thing tab A, res int K)

given | N>0

need | K - the number of maximum elements in table A

alg Resistance (args things R1, R2, args int N, res things R)

given | N>5, R1>0, R2>0

need | R - circuit resistance

Here in sentences given And necessary after the "|" sign comments recorded. Comments can be placed at the end of any line. They are not processed by the translator, but make the algorithm much easier to understand.

Basic function words of the algorithmic language:

alg (algorithm) sim (symbolic) given for yes

arg (argument) lit (literal) necessary from no

rez (result) log (logical) if before when

beginning (beginning) tab (table) then value selection

end (end) nc (start of cycle) otherwise and input

int (integer) kts (end of loop) all or output

thing (real) length (length) not yet approved

Basic commands:

1. Assignment command. Used to evaluate expressions and assign their values ​​to variables. General view: A:= B, where is the sign ":=" means a command to replace the previous value of the variable on the left side with the calculated value of the expression on the right side.

For example: a:= (b+c) * sin(Pi/4); i:= i+1.

Input and output commands.

input variable names (keyboard input)

conclusion variable names, expressions, texts. (display data on screen)

Branching commands.

These commands provide, depending on the result of checking the condition (yes or no), the choice of one of the alternative ways of operating the algorithm. Each path leads to a common output, so the algorithm will continue to run no matter which path is chosen.

The branching structure comes in four main variations:

1. Team if - then;

If condition

That actions

2. Team if - then - otherwise;

If condition

That actions 1

otherwise actions 2

3. Team choice;

Choice

at condition 1: actions 1

at condition 2: actions 2

. . . . . . . . . . . .

at condition N: actions N

4. Team choice is different.

Choice

at condition 1: actions 1

at condition 2: actions 2

. . . . . . . . . . . .

at condition N: actions N

otherwise actions N+1

Cycle commands.

Provides repeated execution of a certain set of actions, which is called the body of the loop.

There are two commands for organizing loops:

1. Loop type Bye - Orders the body of the loop to be executed as long as the condition written after the word is satisfied Bye.

nc Bye condition

loop body

(sequence of actions)

kts

2. Loop type For - Instructs to execute the loop body for all values ​​of a certain variable (loop parameter) in a given range.

nc For i from i1 to i2

loop body

(sequence of actions)

kts

PROGRAMMING LANGUAGES

Currently, there are several hundred actually used programming languages ​​in the world. Each has its own area of ​​application.

Any algorithm, as we know, is a sequence of instructions, following which you can move from the initial data to the result in a finite number of steps. Depending on the degree of detail of the instructions, the level of the programming language is usually determined - the less detail, the higher the level of the language.

Programming language(algorithmic language) - a set of rules that determine what sequences of symbols make up a program (syntactic rules) and what calculations the program describes (semantic rules).

Programming languages ​​have the following characteristics:

  • Language level - characterized by the complexity of problems solved using this language.
  • Power of language - characterized by the number and variety of problems, algorithms for solving which can be written using this language.
  • Reliability - the language should provide a minimum of errors when writing programs. Moreover, the language must be such that incorrect programs are difficult to write.
  • Readability b - ease of perception of programs by humans. This characteristic is important during teamwork, when several people work with the same program texts.
  • Completeness - characterizes the ability to describe a class of problems in a certain subject area.
  • Flexibility - characterizes the ease of expression of necessary actions.

Based on this criterion, the following levels of programming languages ​​can be distinguished:

  • machine;
  • machine-oriented (assemblers);
  • machine-independent (high-level languages).

Machine languages ​​and machine-oriented languages ​​are languages low level, requiring specification of fine details of the data processing process. High-level languages, on the other hand, imitate natural languages ​​by using some words from the spoken language and common words. mathematical symbols. These languages ​​are more human-friendly.

High level languages ​​are divided into:

  • procedural (algorithmic)(Basic, Pascal, C, etc.), which are intended for an unambiguous description of algorithms; to solve a problem, procedural languages ​​require the procedure for solving it to be explicitly written down in one form or another;
  • logical ( Prolog, Lisp, etc. ) , which are focused not on developing an algorithm for solving a problem, but on systematic and formalized description tasks so that the solution follows from the compiled description;
  • object-oriented(Object Pascal, C++, Java, etc.), which are based on the concept of an object that combines data and actions on us. A program in an object-oriented language, solving a certain problem, essentially describes a part of the world related to this problem. Describing reality in the form of a system of interacting objects is more natural than in the form of interacting procedures.

Creating a computer program includes the following stages:

§ analysis;

§ design;

§ programming;

§ testing and debugging;

§ operation.

To date, there are six generations of programming languages. Each of the subsequent generations is qualitatively different in its functional capacity from the previous one.

  • First generation: Machine languages. Appeared in the mid-40s of the XX century.
  • Second generation: Assemblers. In fact, these are the same machine languages, but more beautifully “wrapped”. Appeared in the late 50s of the XX century
  • Third generation: Procedural languages. Appeared in the early 60s of the XX century. This generation includes universal high-level languages, with the help of which you can solve problems from any area (for example, Algol-60).
  • Fourth generation: Languages ​​for supporting complex data structures(eg SQL). Appeared in the late 60s of the XX century.
  • Fifth generation: Artificial Intelligence Languages(eg Prolog). Appeared in the early 70s of the XX century.
  • Sixth generation: Neural Network Languages(self-learning languages). Research work in this area began in the mid-80s of the 20th century.

CONCLUSION

In order for a computer to perform any task, it needs to execute a specific program. The program must be written according to strict rules, in a form accessible for processing on a computer. This set of rules is called a programming language or algorithmic language. Knowing general principle building and writing programs on a computer, you can solve almost any problem necessary in the work of information processing.


Close