Difficulties in learning programming in the end, why should I not learn? The answer never won countless praise it! !

Preface:

Programming in the end Difficulties? DJ Hitori users answered won countless praise.

       This answer is not about how to buy Apple programmers in life, but to buy Apple's an example of how programmers to solve the problem.

       Programmers need to issue thorough analysis, sort out all the details of it relates to predict all accidental and non-accidental can happen, list all the steps of the solution, as well as possible solutions fully tested. Which is what programming is difficult to place. Any omission will become a little bug, ranging from lead scolded, while resulting in economic losses and even endanger safety.

Original answer:

Ordinary people:

I want to buy a pound of apples today.

 

programmer:

I want to buy a pound of apples today.

Because I only like Fuji apples, so I just bought a Fuji apple.

I can accept the highest price is 10 yuan / kg.

Under normal circumstances a pound of apples with a bag can hold, but just in case, I'll take two bags.

I know of three nearby fruit shop, so I'll turn this visit three fruit shop.

According to the above conditions, I buy Apple designed the following process:

How about this process? I come to design some test cases to test this process.

Test found a problem: If the fruit shop fruit shop 0 and 1 are Fuji apples and price below 10 yuan / kg, the price of a fruit shop and fruit shop is lower than 0, then I want to buy apple fruit shop 1 but I design process will allow me to buy fruit shop 0 apple.

To solve this problem, I should first of all fruit shop asking price, and then go to the lowest price that a buy Apple.

Modified, I redesigned following buy Apple's process:

Now this process is not perfect it? No, I can find a lot of problems.

       If three of Fuji apple fruit shop but do not have to pound, but three stores together to achieve a pound, then I should not be the end of the process to go home, but should Sanjiadian Fuji apple buy them.

       If I asked the price of the fruit shop when the store as well as Fuji apples, but after I finished all the fruit shop asking price of Fuji apple store sold out, so I tried to make my flow process that does not exist Fuji apple.

       May be faced with an emergency procedure I walk in, for example, found a new fruit shop, such as a bag of rip off Apple, the process for these cases I can not be processed.

       Ah, too many questions I too lazy to change the process. I still go to X treasure to buy it. Then the next I want to design a process in X Bao buy Fuji apple ......

— END —

       Discovery of the New World program is not it? But programming is hard, also beat our love for programming, a group of small partners together to learn programming is very important! If you are interested or in need, then I have a zero-based introductory programming learning exchange clubs , as well as learning video files, are welcome beginners and advanced in little friends!

Published 520 original articles · won praise 132 · views 80000 +

Guess you like

Origin blog.csdn.net/HUYA69/article/details/105071356