Lessons learned on the way to the great god, continuous update ing (3)

Source: Internet
Author: User

At present, nearly 300 more questions have been brushed, or to talk about problems encountered in the process of solving it.

1. One of the most common mistakes is to design a program based on a sample that is so deep that it replaces some of the variables in the program directly with the values in the sample input, so that the whole problem can only be a fraction of the score. It is suggested that in the process of solving the problem, these variables should be described in words, otherwise the brain short circuit in the back is confused by the constant instead of the variable. For example, the topic says to enter n users, but the sample gave 7 users, then some people in the programming process forget the meaning of N, will be directly replaced by 7来, of course, this can also through the sample, the number of variables is relatively easy to find errors, but a lot of variables is a bit difficult to find the problem.

2. When designing a program, you can use arrays to represent the same type of data as much as possible by using arrays to map representations. For example, the topic says to calculate each student ' C ', ' M ', ' E ', ' a ' four-door grades, do not have to calculate the ranking of each score, but use the array + structure to store the relevant information of these subjects (including ranking score ID, etc.), if it involves priority, Putting priority as an attribute directly into the structure is.

3. When solving some of the problems that require query operations, it is often declared that an array of structures is used, and that the array subscript is consistent with an attribute of an array element, such as ID, so that it is convenient to query. Also, when outputting certain information, make sure that they are not actually modified, that it is possible that you are modifying only a copy, and that the original contents of the containers in which you entered the information have not changed. For example, declare a queue, enter the data you use an array to install, you think you should use queues to work with the data, but it's just a copy of the array element, and you're going to have nothing to do with the elements in the team, so you need to extract some information from the team element and then associate it with the original array. For example, the ID of the element in the team, you can use this ID to index the elements of the array, and then to change the contents of the array elements. Summary is the use of what the data, it is necessary to change what the data, the intermediary container is only an auxiliary.

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.