正在加载图片...
1.1 Program Organization and Control Structures 5 Kernighan,B..and Ritchie,D.1978.The C Programming Language (Englewood Cliffs,NJ: Prentice-Hall).[2][Reference for K&R"traditional"C.Later editions of this book conform to the ANSI C standard.] Meeus,J.1982.Astronomical Formulae for Calculators,2nd ed.,revised and enlarged (Rich- mond,VA:Willmann-Bell).[3] 1.1 Program Organization and Control Structures 83g We sometimes like to point out the close analogies between computer programs, on the one hand,and written poetry or written musical scores,on the other.All three present themselves as visual media,symbols on a two-dimensional page or computer screen.Yet,in all three cases,the visual,two-dimensional,frozen-in-time representation communicates (or is supposed to communicate)something rather different,namely a process that unfolds in time.A poem is meant to be read;music, 令 played;a program,executed as a sequential series of computer instructions In all three cases.the target of the communication.in its visual form.is a human being.The goal is to transfer to him/her,as efficiently as can be accomplished, the greatest degree of understanding,in advance,of how the process will unfold in time.In poetry,this human target is the reader.In music,it is the performer.In 8% 9 programming,it is the program user Now,you may object that the target of communication of a program is not a human but a computer,that the program user is only an irrelevant intermediary, a lackey who feeds the machine.This is perhaps the case in the situation where 6 the business executive pops a diskette into a desktop computer and feeds that computer a black-box program in binary executable form.The computer,in this case,doesn't much care whether that program was written with"good programming practice”or not. We envision,however,that you,the readers of this book,are in quite a different 10621 situation.You need,or want,to know not just what a program does,but also how Numerica it does it,so that you can tinker with it and modify it to your particular application. You need others to be able to see what you have done,so that they can criticize or admire.In such cases.where the desired goal is maintainable or reusable code.the g多 targets of a program's communication are surely human,not machine. One key to achieving good programming practice is to recognize that pro- gramming,music,and poetry-all three being symbolic constructs of the human brain-are naturally structured into hierarchies that have many different nested levels.Sounds(phonemes)form small meaningful units(morphemes)which in turn form words;words group into phrases,which group into sentences;sentences make paragraphs,and these are organized into higher levels of meaning.Notes form musical phrases,which form themes,counterpoints,harmonies,etc.;which form movements,which form concertos,symphonies,and so on. The structure in programs is equally hierarchical.Appropriately,good program- ming practice brings different techniques to bear on the different levels [1-31.At a low level is the ascii character set.Then,constants,identifiers,operands,operators.1.1 Program Organization and Control Structures 5 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machine￾readable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). Kernighan, B., and Ritchie, D. 1978, The C Programming Language (Englewood Cliffs, NJ: Prentice-Hall). [2] [Reference for K&R “traditional” C. Later editions of this book conform to the ANSI C standard.] Meeus, J. 1982, Astronomical Formulae for Calculators, 2nd ed., revised and enlarged (Rich￾mond, VA: Willmann-Bell). [3] 1.1 Program Organization and Control Structures We sometimes like to point out the close analogies between computer programs, on the one hand, and written poetry or written musical scores, on the other. All three present themselves as visual media, symbols on a two-dimensional page or computer screen. Yet, in all three cases, the visual, two-dimensional, frozen-in-time representation communicates (or is supposed to communicate) something rather different, namely a process that unfolds in time. A poem is meant to be read; music, played; a program, executed as a sequential series of computer instructions. In all three cases, the target of the communication, in its visual form, is a human being. The goal is to transfer to him/her, as efficiently as can be accomplished, the greatest degree of understanding, in advance, of how the process will unfold in time. In poetry, this human target is the reader. In music, it is the performer. In programming, it is the program user. Now, you may object that the target of communication of a program is not a human but a computer, that the program user is only an irrelevant intermediary, a lackey who feeds the machine. This is perhaps the case in the situation where the business executive pops a diskette into a desktop computer and feeds that computer a black-box program in binary executable form. The computer, in this case, doesn’t much care whether that program was written with “good programming practice” or not. We envision, however, that you, the readers of this book, are in quite a different situation. You need, or want, to know not just what a program does, but also how it does it, so that you can tinker with it and modify it to your particular application. You need others to be able to see what you have done, so that they can criticize or admire. In such cases, where the desired goal is maintainable or reusable code, the targets of a program’s communication are surely human, not machine. One key to achieving good programming practice is to recognize that pro￾gramming, music, and poetry — all three being symbolic constructs of the human brain — are naturally structured into hierarchies that have many different nested levels. Sounds (phonemes) form small meaningful units (morphemes) which in turn form words; words group into phrases, which group into sentences; sentences make paragraphs, and these are organized into higher levels of meaning. Notes form musical phrases, which form themes, counterpoints, harmonies, etc.; which form movements, which form concertos, symphonies, and so on. The structure in programs is equally hierarchical. Appropriately, good program￾ming practice brings different techniques to bear on the different levels [1-3]. At a low level is the ascii character set. Then, constants, identifiers, operands, operators
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有