Thoughts on pseudocode

Source: Internet
Author: User

Coding is to solve a certain problem (whether it is a question on OJ or a project). Before solving the problem, we should fully analyze the problem (mining the implied conditions of the question, analysis of project requirements), coding becomes a matter of course only after you fully understand the problem and have a clear idea. In the past, when I was doing a question on OJ, I used to write code when I saw the question and never analyzed the various conditions of the question. This is wrong.

★What is pseudocode?

Is an algorithm description language. It has many rules. In fact, this is easy to understand. Just like Qin Shihuang's Unified Text and currency. Only with a unified standard can it be widely used. For a development team, using this pseudo code makes it easy for others to understand their own ideas or ideas. But for individuals (if they only want to come to OJ to do a question), they feel that they can ignore these so-called rules, but simply express their ideas for solving problems clearly, you can understand it yourself.

★Benefits of pseudocode

Pseudocode has a clear idea of how to solve the problem. After the problem is analyzed, some solutions will be made. After these ideas are clearly expressed using pseudocode, the code will continue based on this idea. At the same time, they will also inspire their own ideas and think of a variety of solutions to the problem.

★Instance analysis

Analyze a very simple question.

Question: output all the four-digit full numbers (that is, the first two digits are equal, and the last two digits are equal) in the form of AABB)

From the question, we can know that AABB is a four-digit number, so! = 0, but B can be = 0. Then, it is easy to get the following idea:

For (A = 1; A <10; A ++) {for (B = 0; B <10; B ++) {If (AABB is the total number of bytes) printf ("% d", AABB );}}

Here, there are two small issues: the first is how the number of AABB is expressed, and the second is how the sentence "AABB is a full number of partitions" is expressed. If you solve these two problems, this program will solve them!

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.