正在加载图片...
Introduction9 .program stops and the value n=9 Largest_Value_So_Far=-inf i=0 i=i+1 Yes No NoV()Largest Value_So_Far? Yes Largest_Value_So_Far=V() Print Largest_Value_So_Far Figure1.6.1 A flowchart like this can serve as the conceptual foundation for the code needed to get a computer to find the largest value in an array.You don't have to draw a flowchart before you write MATLAB code,however.Some people only imagine flowcharts or the steps corresponding to them.Drawing flowcharts in your head obviously gets easier as you get more practice with programming.Early in practice,however,it is advisable to sketch the steps your programs will follow. How do you come up with a flowchart or its corresponding steps in the first place?The honest answer is that no one knows.Anyone who could give the answer would,in effect know how thoughts originate,and no one at this time has a clue about that.If you solve this problem,a Nobel Prize awaits you. You can,however,consider some practical advice about how to come up with the proce dures One suggestion is to t out Iou Imagine yourse n,step by s ,m ry car to mak e expl th Ir. P oK next I'll t he erion I can't quite ready to write all the ode ou need.Ultimately u'll need to be about the instructionsy ms contain.Relvins omiracle just w on't work and toe cis that computers for al their speed.are ignorant and infle ible.They do exactly and only what they're told to do.Introduction 9 Largest_Value_So_Far. When i is larger than n , the program stops and the value of Largest_Value_So_Far is printed out. Figure 1.6.1 A flowchart like this can serve as the conceptual foundation for the code needed to get a computer to find the largest value in an array. You donÊt have to draw a flowchart before you write MATLAB code, however. Some people only imagine flowcharts or the steps corresponding to them. Drawing flowcharts in your head obviously gets easier as you get more practice with programming. Early in practice, however, it is advisable to sketch the steps your programs will follow. How do you come up with a flowchart or its corresponding steps in the first place? The honest answer is that no one knows. Anyone who could give the answer would, in effect, know how thoughts originate, and no one at this time has a clue about that. If you solve this problem, a Nobel Prize awaits you. You can, however, consider some practical advice about how to come up with the proce￾dures for computer programs. One suggestion is to talk out loud as you imagine yourself doing the task you wish to program, step by step, much as we did with the imaginary card above. Talking out loud may enable you to make explicit whatever implicit knowledge you bring to bear as you do the task, as if you were explaining the task to a friend. Hearing your own words will also help you identify those things youÊre not clear about. If you hear yourself say, „OK, next IÊll somehow figure out which of the values might be OK based on some criterion I canÊt quite articulate but I have a vague feeling about,‰ then youÊre not quite ready to write all the code you need. Ultimately, youÊll need to be completely explicit about the instructions your programs contain. Relying on a miracle just wonÊt work, and the reason, just to be explicit, is that computers, for all their speed, are ignorant and inflex￾ible. They do exactly and only what theyÊre told to do
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有