15 basic algorithm questions with extremely high frequency (with complete code) and extremely high Algorithms

Source: Internet
Author: User

15 basic algorithm questions with extremely high frequency (with complete code) and extremely high Algorithms

Algorithm pseudocode for a question

I wrapped up this question, and others quickly dispersed. I will tell you the answer tomorrow. Of course, it's just a thought. I have always been a fisherman, not a fish.

I am asleep. Now I will answer your question. Thank you for your support! By the way, I feel that the old outing question is brilliant. I didn't have such a good question to guide the students when I went to school.

Let's take a look at the question first, instead of focusing too much on the details. We can summarize this question in one sentence, which is to convert a series of blocks into messages, and the message consists of multiple pages. This is the high abstraction of a program.

The second step shows what you can use, that is, the three subprograms mentioned in Article 8th. You need to write some programs to call these three subprograms to achieve your goals.

Write multiple blocks and convert them into a message method, and then call this method continuously.

In two steps, the first step is to obtain multiple blocks that constitute a message. The pseudocode is as follows:
While (true)
{
GetBlock;
If (lastBlock. text = "#")
{
Break; // If the block you just obtained contains only one #, it indicates the end of a message. Exit the loop. The array contains all blocks that constitute a message.
}
}
Second, construct a message based on these blocks. Remove spaces at the beginning and end of the block text, and then convert multiple consecutive spaces into one space.
Then, put each word in the block into a temporary string in sequence. Every time the string has enough 100 words, putline is called. If it is not enough, it is not enough to add the next one, if it is too old, do not next, because a word cannot wrap. PutPage is called every 60 lines written until all blocks are used up.

A For-type pseudo-code algorithm

1 9
 

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.