Basic programming training: Flowchart painting and exercises

Source: Internet
Author: User

For the work of "Program Design", many people who have just started to learn are "writing code ". Likewise, newbies are troubled by the fact that they only "write code ". When receiving a new task, many people always climb to the keyboard and tap the code in the first place. As I knocked on it, I was confused. Dizzy, stick to it, the program can be executed, amittofo, hurry to withdraw. This process is not reliable.
In programming, the most important thing is not coding, But designing. Like the construction, machinery and other industries to draw design drawings, construction drawings, the idea of program design is also necessary to draw out in the form of diagrams. The process of drawing is the process of thinking. Because of its intuition, the process of drawing itself promotes thinking. A variety of useful diagrams have been developed in software projects to ensure the quality of software product design. This part of the exercise helps programmers master and practice the "program flow chart ".
1. What is a program flowchart?

"Program flowcharts" are commonly referred to as "flowcharts" and are a traditional algorithm representation. Program Flowcharts are a descriptive description of the methods, ideas, or algorithms used to solve this problem. It uses graphical symbol boxes to represent various operations of different nature and uses process lines to connect these operations. In the program design (before coding) stage, by drawing a flowchart, we can clarify the program ideas. It is a simple flowchart describing the algorithm used to calculate the maximum common divisor of two numbers (moving phase division ).


The flowchart is the basic skill of every programmer. The flow chart has its own specifications. This is used for communication between technical personnel. The symbols frequently used in the flowchart are shown in the right figure. Find the corresponding part in the preceding flowchart for finding the maximum common number.


2. flowchart representation of three control structures

This part will not be written, but will be written in various programming textbooks. At least when talking about various control structures, we will always talk about it. Please refer to the teaching materials you can find and carefully taste them.
We will directly remind you of a number of tasks and draw a picture.


3. Exercise questions (select at least two pictures for each part, and note that you should use a piece of good quality paper to write neatly, so that the painting will become happier)

1. Warm up
(1) convert feet to meters
(2) enter the coordinates of the two points, calculate the distance between the two points, and output
2. Branch Program
(1) Describe the plan for tonight: If it's snowing, it's snowing on campus; otherwise, you will be on the machine at 103 (MISs)
(2) Losing coins decides tonight: Front, kge; back: shopping; stand up, learn C ++

(3) evaluate the function value:

(4) input the coefficients of the quadratic equation ax ^ 2 + bx + c = 0, and based on the values of the coefficients, solve the problem separately (reduce the difficulty for yourself when the various factors may be too complex, and start from directly solving the problem without considering the system)
(5) input the total monthly income of an individual and calculate his tax payable and post-tax income this month (tax rate and other 9th-week tasks)
3. Loop Structure
(1) calculate 1 + 2 + 3 +... + 100 (draw one of the three cycle structures)
(2) Output 1/3-3/5 + 5/7-7/9... + 19/21 results
(3) A number is assumed to be equal to the sum of its factors. This number is called "complete number ". Find the total number of completions within 1000.
(4) output the number of all replies within 1000
(5) Chicken Weng Yi, worth five, chicken and mother, worth three, three chicks, worth one, and a hundred dollars. How can I buy them?
4. Programs with Complex Structures

In solving this problem, the use of functions allows us to think about the problem with a more "orderly" thinking, "from top to bottom, gradually improving", truth. For example, the following flowchart is used to output an asterisk (*). the diagram on the right can be embedded in the left to replace the box "output line I, it can also guide us to specially compile a function.

Task:
(1) Output all return prime numbers of less than 10000. Separate the inferred ECHO and the inferred prime number, and use the function to implement these two functions.
(2) Draw a flowchart of the banking system (the detailed business point ends, not all)


Note: in traditional teaching, if you have not learned to write code, you must first learn the painting process. In practice, I felt that the effect was not good. Controls why the structure is dizzy and how it can be drawn. There is a certain programming experience before painting, is the idea of reform. This is a basic programming skill and must be mastered!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.