下面是我读《Programming in C++》第一章的笔记,如果您想找一些C++编程入门的知识,或是打算初步煅炼自己读原版书的水平,那么这是最适合的,极力推荐您读一下。在这篇读书笔记中,将摘录书中的重点内容并在难懂的地方进行汉语标注,最合初学者阅读。
chapter 1 Overview of Programming and Problem Solving
Goals
· To understand what a computer program is.
· To be able to list the basic stages involved in writing a computer program.(能够列出,书写计算机程序涉及的基本步骤.)
· To understand what an algorithm(算法) is.
· To learn what a high-level programming language(高级程序设计语言) is.
· To be able to describe what a compiler(编译程序) is and what it does.
· To understand the compilation(编译) and execution processes.
· To learn what the major components(组件) of a computer are and how they work together.
· To be able to distinguish(区分) between hardware and software.
· To be able to choose an appropriate(适合的) problem-solving method for developing an algorithmic solution to a problem.
1.1 Overview of Programming
What Is Programming?
Programming: Planning or scheduling(安排,明细表) the performance(执行) of a task or an event.
Computer: A programmable device(可编程的装置) that can store, retrieve(检索), and process data(处理数据).
Computer programming: The process(过程) of planning a sequence(序列) of steps for a computer to follow.
Computer program: A sequence of instructions(命令) to be per-formed by a computer.
How Do We Write a Program?
To write a sequence of instructions for a computer to follow, we must go through a two-phase process(我们必须通过两个过程):
problem solving and implementation.
Problem-Solving Phase
1. Analysis and specification(具体指明). Understand (define) the problem and what the solution must do.
2. General solution (algorithm). Develop a logical sequence of steps that solves the problem.
3. Verify. Follow the steps exactly to see if the solution really does solve the problem.
Implementation Phase(执行阶段)
1. Concrete(具体) solution (program). Translate the algorithm into a programming language.
2. Test. Have the computer follow the instructions. Then manually(人工的) check the results. If you find errors, analyze
the program and the algorithm to determine the source of the errors, and then make corrections(改正).
Once a program has been written, it enters a third phase: maintenance(维护).
Maintenance Phase
l. Use. Use the program.
2. Maintain. Modify the program to meet changing requirements or to correct any errors that show up in using it.
The programmer begins the programming process(程序过程) by analyzing the problem and developing a general solution called
an algorithm. They are the heart of the programming process.
Algorithm: A step-by-step procedure(步进法) for solving a problem in a finite(有限的) amount of time.
After developing a general solution, the programmer tests the algorithm, walking through each step mentally(内心地) or manually(手工地). If the algorithm doesn't work, the programmer repeats the problem-solving process, analyzing the problem again and coming up with(提出).