Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатика
ИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханика
ОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторика
СоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансы
ХимияЧерчениеЭкологияЭкономикаЭлектроника

Stages of construction of algorithm with structural scheme use

Читайте также:
  1. ANCIENT TERMS OF UKRAINIAN LAW: ETYMOLOGICAL RECONSTRUCTIONS AND SEMANTIC OBSERVATIONS
  2. Bodhisattvahood and Its Stages
  3. Chronological resume template (pipe line and oil field construction specialist)
  4. COMPOSITE SENTENCE AS A POLYPREDICATIVE CONSTRUCTION 1 страница
  5. Construction basics
  6. Construction work
  7. CONSTRUCTIONAL HOMONYMITY

First step of writing of program is generalized description of algorithm. It is block-scheme or structural scheme of problem. Structural scheme (block diagram, flow diagram, skeleton diagram, flowgraph) use conventional signs on this step. Such sign is the shape specific for certain kind of actions.

Most important signs are:

Process. It corresponds to series of successively executing actions or calculations.

 
 


Solution. It denotes checking of condition. Further actions depend on result of solution.

 

Completion. It is finish of algorithm.

       
   


Input-output (without details). Input-output on the disk.

 
 


Output onto the display.

 
 


Saving of data.

 

Knot. It is place of merging of two (or more) branches of algorithm.

 

Elements of block-scheme are bound by arrows.

Basic structures of algorithm in scheme:

1. successive carrying out;

2. conditional carrying out (alternating);

3. branching, which is succession of conditional carrying out.

4. cycle (repetition);

There are images of their structures.

 
 

Part of algorithm, whose execution depends on condition, has name “loop body“. Iteration is one repetition of this part of algorithm.

Cycle “after” is cycle with condition check after one execution of loop body. This cycle has feature: loop body will be in progress as minimum once.

Cycle “before” is cycle with condition check before execution of loop body. In this case it is possible situation without execution of loop body operators.

When general structure is clear, step of construction of algorithm is analysis of inner structure of algorithm and its detailing.

Finals description (program) consist of elementary language operators (separate phrases), which are named as code statements or program statements too.

Every algorithm works with information in computer memory, not with real objects. Correspondingly, minimal memory volume with separate certain element of information is marked by special address (for inner computer using) or by name (for human using). This name is variable. Word “variable” is used as value (contents) of memory can change during algorithm work. Very often we tell about this memory unit as about a memory cell (really it can be block of many separate cells, which are used as a single whole). When we change value of variable, check or send information – we carry out some elementary action – we mark this action by operator sign.

For operators conventional signs are used too.

For example, expression "D:=12" means that number “12” is sent to the cell with name “D”. Result of this action will be value “12” in the cell “D” regardless of previous value of cell “D”.

“D=12” means that we check whether value of variable “D” is equal to number “12”. Result of this action will be presence of value “true” or “false” is working memory of computer.

Here “:=” is assignment operator, “=” is comparison operator of equality.

Result of operator “D>12” will be presence of value “true” (if D>12) or “false” (if D≤12) is working memory.

Comparison operators are =, >, <, ≤ (other form <=), ≥ (other form >=).

Mathematical operators are +, –, * (or •) and /. Sign ** very often is used for designation of exponentiation operation.

Statement brackets () are used the same way as in mathematics for change of operations order.

Thus, if we want to send result of mathematical expression into memory cell with name “C7”, we will write next operator:
C7:=24+(17*67**5)/(124-93).

Order of operations is: at first exponentiation “**” operations are executed, then multiplication “*” and division “/” (they have identical order), and then addition “+” and subtraction “-“. Actions in brackets are executed before result will be used in total expression order. Semicolon “;” symbolizes end of operator very often.

When name of variable is in the right part of operator, it means that value of variable (that is on the moment of memory reading) is used in specified action. It can change, if the same name of variable is left part of operator: it means, that we take old value of variable, use it in expression, and result of expression send to specified cell.

Next example:

A:=24; B:=7; C:=3; A:=A*B+C; C:=B/C

Results of this sequence of operators will be:

A=24

B=7

C=3

A=24*7+3=171

B=7

C=7/3=2.333333333 (this sequence of characters “3” – length of fractional part is limited by computer system).

To obtain result we need to repeat every operator one by one so many times and in that order, which forms during reading of algorithm, as in algorithm can be present operators of order change. There are conditional statements [if clause, conditional, if statement] which can have some direction of exit or transition onto special marked points of algorithm. Conditional statements use comparison operators; they are check points.

In block-scheme one instruction or set of instructions (operators) are inscribed in the every shape. At alternating result of condition check (as “yes” and “no” or “true” and “false”) are denoted above outcoming arrows. At branching exact possible results of condition check are denoted above outcoming arrows.

 

An example: description of average calculation.

Formula:

 
 

Similar block-scheme can be formed for any task. Degree of its detailing can be various; it will depend on complexity of problem and step of work.

N.B. Examples of medical problems that present here are very simple, not real, and not suitable for using in medical treatment practice without addition and correction.

If we form textual algorithm or program, we must use special marked points at the place of trace lines merging (in this example - before input regular number xi). Numbered marks are usual.

 


Дата добавления: 2015-10-30; просмотров: 135 | Нарушение авторских прав


Читайте в этой же книге: Положение о предоставлении льгот для спортсменов ALEX TEAM | Для членов и не членов клубов СФК Alex Fitness и CCK OLYMP | Heuristic and formal. |
<== предыдущая страница | следующая страница ==>
On 2-nd step complicated task is choosing most effective method (by principles of minimization of time, expenditure of labour, minimization of mistake probability and similar).| Алгоритмы и алгоритмические языки

mybiblioteka.su - 2015-2024 год. (0.008 сек.)