ТОР 5 статей: Методические подходы к анализу финансового состояния предприятия Проблема периодизации русской литературы ХХ века. Краткая характеристика второй половины ХХ века Характеристика шлифовальных кругов и ее маркировка Служебные части речи. Предлог. Союз. Частицы КАТЕГОРИИ:
|
The algorithm written by a pseudo and flowcharts.
Questions for the protection of works 1. What is the algorithmic language? 2. What are the main elements of the algorithmic language.
Practical work 4. Construction of a cyclic structure algorithms Objective: To acquire the skills of construction of cyclic algorithms algorithmic language and the language of block diagrams. Task 1. Required to calculate the value of the function y = sin φ in the range of variation of the argument from 10 ° to 90 ° in steps of 10 °. Methodology for setting 1: Stage 1: Formulation of the problem. Input data: X - the angle φ (function argument) NX - the initial value of the angle φ (10 °) KX - the final value of the angle φ (90 °) HX - a step change in the angle φ (10 °) Output: Y - values of the function at the given φ. Stage 2: A mathematical model.
3 этап: Drafting of the algorithm Fig. 3. Example round robin Task 2. Create an algorithm for solving the problem by using algorithmic language and make the block diagram of the algorithm:
1. Find the sum of multiples of three, in the range of 0 to 50. 2. Find the sum of the first ten multiples of five. 3. Find the product of even numbers in the range of 2 to 30. 4. Introduce positive numbers. Stop input, when the amount of the entered number will exceed 100. 5. The amount required to find the numbers that are multiples of 7, in the range from 0 to 100. Display the sum of the numbers and their number. 6. Determine the number of integers that are multiples of 3 (from 3 onwards), giving a total number exceeding 200. 7. introduced 10 numbers. Display the sum of positive and negative numbers and their quantity. 8. Display the values of the function y = sin (x) for 0≤x≤180 c increments of 10. 9. Calculate the area of ten circles with radii of 1 cm in increments of 2 cm and bring the values of the areas on the screen. 10. introduce positive numbers. Stop input numbers when their sum exceeds 100. The result display. 11. to enter numbers. Stop input numbers, when the sum of positive numbers exceed 100. Output display. 12. Display the values of the products of numbers a and b. The numbers range from 1 to 11 in steps of 1, b - 1 to 3 with a step 0.2. 13. Display the translation table of kilometers to miles in the range from 2 to 20 km in increments of 2 km. 14. You put in the bank 1500 rubles. Determine how much money is on your deposit after 1 year if the monthly contribution increases by 0.76% of the previous month. 15. Having decided to do athletics, you ran the first day of 2 km. How many kilometers you run through 2 weeks, every day if you increase the distance by 10% from the previous day?
Technology of work We have to make the algorithm for solving the problem in block diagram form and using pseudocode language as part of the work. The content of the report 1. The purpose of the work and mission. 2. The condition of the problem. 3. The algorithm written by a pseudo and flowcharts. Answers the questions 1. What is a flowchart? 1. What are the main elements of the block diagrams. Practical work 5. Construction of sorting algorithms Objective: To explore the sorting algorithms, algorithms learn to be on the Shell method. Task 1. Let a sequence of 5 elements 5,4,1,2,3. Sort this sequence sorting method of choice. We will highlight the current element at each step in purple, black and minimum fat. Technology of the task 1.
Task 2. The sequence of numbers: 5,1,4,2,8 and sort the values in ascending order, using the bubble sort. To identify those items that are compared on this stage. First pass:
Second pass:
Now the array is completely sorted, but not optimized algorithm will hold two more passes, in which nothing changes, in contrast to the algorithm using a second optimization, which makes one run and stops its work, as it does not make for the passage of a single exchange. Exercises Task 1. Let a sequence of 10 elements 8,5,6,6,5,5,4,1,2,3. Sort this sequence sorting method of choice. Task 2. Let a sequence of 10 elements 7,5,6,1,5,5,4,1,2,3. Sort this sequence by the bubble. Task 3. Let a sequence of 8 elements 10,6,4,9,2,4,3,8 Sort this sequence by the bubble. Control questions: 1. What sort? 2. Which sorting algorithms do you know? 3. What is the method of the bubble? Practical work 6. Construction of the Turing machine Objective: To acquire the skills of building a Turing machine Task 1. Let A = {0, 1, _}. On the ribbon, in the cells are the characters of the alphabet in the order of 0011011. carriage is on the first character. It is necessary to create a program that will replace 0 to 1, 1 to 0, and the carriage returns to its initial position. Methodology for task 1 Now define the conditions of the carriage. I call them - 'carriage of desire to do something. " q1) carriage must go to the right, if it sees 0 changes to 1 and remains in state q1, if he sees one - change it to 0 and remains in the state q1, if he sees _ - rotates the back at 1 cell "wants chto-to more», ie changes to the state q2. We write our arguments to the table of the performer. Syntax, refer to the Help for the program) q2) now describe the "desire of the carriage» q2. We must return to the original position. To do this: if we see her leave 1 and remain in state q2 (with the same desire to reach the end of a number of characters); if you see a 0 - leave it and continue to move to the left in the state q2; see _ - shifted right one cell. So you got to where needed in the problem. We go to the state q0.
From 001101011101 000000000000 1111111 get. As you can see, seven units recorded after the sequence, and in their place stand toe. We now proceed to the discussion. Determine which state is needed and how the carriage. q1) saw a 1 - to correct the toe and go to another state q2 (new state introduced to the carriage does not return to zero all the units in a single pass) q2) not to change anything, move the end of the sequence q3) as soon as the carriage I saw an empty cell, it takes a step to the right and draw yedinichku if she sees yedinichku - then moves on to sign character at the end. Once painted unit, go to the state q4 q4) pass on the written units, without changing anything. As soon as we reach an empty cell, separating the sequence of units, move to a new state q5 q5) go to the beginning of the sequence, without changing anything in this state. We reach the empty cell, turn around and go to the state q1 Status q0 carriage will take in the event, when it will be held in the state q1 to the end of the sequence, and meet an empty cell. We get such a program: Tasks for the independent decision
Task 3. Turing machine consists of an endless belt and a head which moves relative to the tape, erases the characters, sets the new symbols. Write a program that simulates the operation of a Turing machine, which increases the predetermined number by 2. Task 4. Write a program for MT, down two integers, given a set of units. Task 5. On the tape MT - a finite set of units: _11111__. Write a program that puts an asterisk in place of the first and last units remaining wipes. Task 6. On the tape MT - a finite set of units: _111111__. Write a program that replaces the unit by asterisks. Head - to the left of the first unit. Task 7. On the tape MT - sequence _ABBAABAB____. MT head - in front of the left character. Write a program to the MT group the symbols "A" on the right side of the line, and instead put an asterisk.
Control questions: 1. The device is a Turing machine. 2. A system of commands of the Turing machine. 3. The alphabet of the Turing machine. 4. Options for the end of the program a Turing machine.
Practical work 7. Construction of the Post machine
Objective: To study the program simulator Post machine. Develop the skill of drawing up algorithms for the Post machine. Theoretical part machine Command format Lent has the form: n K m Where: n - current command number; K - a team of system commands Post machine (see Table 1..); m - link - command number to be executed next.
In order to fill the tape is enough to bring the cell the mouse and double-click the left mouse button, or use the button . - stores the initial state of the tape. - Restores the initial condition of the tape. - Starts the program algorithm to perform. - Stepping through the program. - Stop the program.
Setting text: The report carried out in electronic form. If the rows of the table to describe the program algorithm is not enough they are not necessary to add. If several jobs, then repeat the entire system as many times report. Report back Insert a screenshot of the initial state of the tape.
Insert a screenshot of the tape after the state of the algorithm.
Fill in the table inscribing the algorithm of the program commenting on each line.
Assignments for practical work
Exercise 1 Create a program information transfer ribbon from the initial to the final state: Variant 1
Variant 2
Variant 3
Variant 4
Variant 5
Variant 6
Variant 7
Variant 8
Variant 9
Variant 10
Variant 11
Variant 12
Task 2 Perform arithmetic operations: 8. 3+4, 4-2; 9. 5+3, 3*2; 10. 5-2, 2*2; 11. 5-4, 6/2; 12. 3+2, 4/2; 13. 2+4, 2*4; Task 3 Create a program for the passage of the carriage from the left mark to the right. The number of empty cells between the marks is not known.
Task 4 Create a program to fill all the cells of the left mark to the right. The number of empty cells between the marks is not known.
Task 5 Create a program information transfer ribbon from the initial to the final state. Number of labels arbitrary (not necessarily equal to 4).
Task 6 Create a program information transfer ribbon from the initial to the final state. Number of labels arbitrary (not necessarily equal to 4).
Control questions: 1. The device Post machine 2. The system commands the Post machine. 3. Alphabet Post machine. 4. Options for the end of the program on the Post machine. 5. Writing
Practical work 8. Linear programming in QBasic Objective: To get the skills of construction of linear programming in QBasic Methods of work Task 1. To indicate the length and height of the wall used numerical variables L and H. Write a program to calculate the area of the wall. LET L = 8 LET H = 3 LET S = L*H PRINT «Area is»; S In this program are assigned specific values of the variables L and H. However, this program can be written in another form: INPUT «Enter the length of the wall»; L INPUT «Enter the height of the wall; H LET S = L * H PRINT «area is"; S Не нашли, что искали? Воспользуйтесь поиском:
|