C++ Chapter 02
- 格式:ppt
- 大小:745.00 KB
- 文档页数:48
Chapter 1 Fluid statics 流体静力学1. 连续介质假定(Continuum assumption):The real fluid is considered as no-gap continuousmedia, called the basic assumption of continuity of fluid, or the continuum hypothesis of fluid. 流体是由连续分布的流体质点(fluid particle)所组成,彼此间无间隙。
它是流体力学中最基本的假定,1755年由欧拉提出。
在连续性假设之下,表征流体状态的宏观物理量在空间和时间上都是连续分布的,都可以作为空间和时间的函数。
2. 流体质点(Fluid particle ): A fluid element that is small enough with enough moles to makesure that the macroscopic mean density has definite value is defined as a Fluid Particle. 宏观上足够小,微观上足够大。
3. 流体的粘性(Viscosity ): is an internal property of a fluid that offers resistance to sheardeformation. It describes a fluid's internal resistance to flow and may be thought as a measure of fluid friction. 流体在运动状态下抵抗剪切变形的性质,称为黏性或粘滞性。
它表示流体的内部流动阻力,也可当做一个流体摩擦力量。
The viscosity of a gas increases with temperature, the viscosity of a liquid decreases with temperature. 4. 牛顿内摩擦定律(Newton’s law of viscosity ):5. The dynamic viscosity (动力黏度)is also called absolute viscosity (绝对黏度). The kinematicviscosity (运动黏度)is the ratio of dynamic viscosity to density.6. Compressibility (压缩性):As the temperature is constant, the magnitude ofcompressibility is expressed by coefficient of volume compressibility (体积压缩系数) к , a relative variation rate (相对变化率) of volume per unit pressure.The bulk modulus of elasticity (体积弹性模量) E is the reciprocal of coefficient of volumecompressibility к.7. 流体的膨胀性(expansibility; dilatability):The coefficient of cubical expansion (体积热膨胀系数) αt is the relative variation rate of volume per unit temperature change.8. 表面张力Surface tension : A property resulting from the attractive forces betweenmolecules. σ-----单位长度所受拉力9. 表面力 Surface force ——is the force exerted on the contact surface by the contacted fluidor other body. Its value is proportional to contact area. 作用在所研究流体外表面上与表du dzτμ=μνρ=面积大小成正比的力。
8第 章 C++程序的组成及开发过程◆ C++程序的开发过程◆ C++程序的组成部分 ◆ 编译器和编译过程◆ C++程序的开发环境 ◆ C++程序的调试方法◆ 开发多文件程序的过程C++程序由数据(常量、变量,包括对象)和函数组成。
本书将分别对各个组成部分进行介绍。
但是,如何将各个部分组织成一个完整的程序,才是本书的重点。
本章从一个简单的程序开始,讲述一个完整程序的组成以及C++程序的开发过程。
2.1 一般开发过程C 和C++程序的开发一般要经历4个过程:编辑、编译、链接、运行。
编辑:将程序的设计思想转换成代码。
编译:将代码转换成机器码。
链接:将程序编译后的各部分机器码和C++库函数等链接成一个可执行程序。
运行:在计算机上执行上述可执行程序。
如果源代码中没有任何错误,那么开发可以一次完成。
在实际开发中,任何程序多多少少总会存在一些问题。
这些问题包括语法、逻辑方面的错误,也包括效率方面的损失。
如果是语法方面的错误,则在程序编译过程中就会出错,编译器会给出错误提示。
开发者可以根据这个错误提示修改源代码,然后重新编译。
链接的过程中也可能出错,其原因可能是程序中引用的某个函数或者某个变量不存在,或者程序中使用的静态链接库或动态链接库不存在。
关于链接错误的讨论超出了本书的范畴,因此在这里不做更多的说明。
如果是逻辑方面的错误(比如程序的输出不是预期的结果),或者运行效率很低,则没有明显的错误提示。
开发者要么根据自己的经验去纠正错误,要么利用调试器对程序进行调试,找到原因所在。
因此,在大多数情况下,开发程序还包括一个调试的过程。
所谓调试,就是在程序运行过程中,监视相关源代码的执行情况。
一般来讲,程序在编译之后会变成机器码,而机器码对于人来讲是非常难以阅读的。
根据机器码找到运行过程中的错误非常困难,所以应当利用一个调试器,在程序运行过程中,监视可读性好的源代码的执行情况。
一旦错误被发现,就必须修正。
这包括重新编辑源代码、重新编译、重新链接、重新运行程序以及重新调试。
// chapter 01/*#include <stdio.h>int main(void){int dogs;printf("How many dogs do you have?\n");scanf("%d", &dogs);printf("So you have %d dog(s)!\n", dogs);return 0;}*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////chapter 02// fathm_ft.c -- converts 2 fathoms to feet/*#include <stdio.h>int main(void){int feet, fathoms;fathoms = 2;feet = 6 * fathoms;printf("There are %d feet in %d fathoms!\n", feet, fathoms);printf("Yes, I said %d feet!\n", 6 * fathoms);return 0;}*////////////////////////////////////////////////////////////////////*#include <stdio.h>int main(void) // a simple program{int num; // define a variable called numnum = 1; // assign a value to numprintf("I am a simple "); // use the printf() functionprintf("computer.\n");printf("My favorite number is %d because it is first.\n",num);return 0;}*///////////////////////////////////////////////////////////////////// two_func.c -- a program using two functions in one file/*#include <stdio.h>void butler(void); // ISO/ANSI C function prototypingint main(void){printf("I will summon the butler function.\n");butler();printf("Yes. Bring me some tea and writeable CD-ROMS.\n");return 0;}void butler(void) // start of function definition{printf("You rang, sir?\n");}*///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////chapter 03 数据和C/*// altnames.c -- portable names for integer types#include <stdio.h>#include <inttypes.h> // supports portable types the system doesn't contain the header fileint main(void){int16_t me16; // me16 a 16-bit signed variableme16 = 4593;printf("First, assume int16_t is short: ");printf("me16 = %hd\n", me16);printf("Next, let's not make any assumptions.\n");printf("Instead, use a \"macro\" from inttypes.h: ");printf("me16 = %" PRId16 "\n", me16);return 0;}*///////////////////////////////////////////////////////////////////// bases.c--prints 100 in decimal, octal, and hex#include <stdio.h>int main(void){int x = 100;printf("dec = %d; octal = %o; hex = %x\n", x, x, x);printf("dec = %d; octal = %#o; hex = %#x\n", x, x, x);//%# 十六进制前显示Ox //八进制数前显示oreturn 0;}*////////////////////////////////////////////////////////////////*// charcode.c-displays code number for a character#include <stdio.h>int main(void){char ch;printf("Please enter a character.\n");scanf("%c", &ch);printf("The code for %c is %d.\n", ch, ch);return 0;}*////////////////////////////////////////////////////////////////*//print1.c-displays some properties of printf()#include <stdio.h>int main(void){int ten = 10;int two = 2;printf("Doing it right: ");printf("%d minus %d is %d\n", ten, 2, ten - two );printf("Doing it wrong: ");printf("%d minus %d is %d\n", ten ); // forgot 2 arguments return 0;*////////////////////////////////////////////////////////////////* print2.c-more printf() properties *//*#include <stdio.h>int main(void){unsigned int un = 3000000000; // system with 32-bit intshort end = 200; // and 16-bit shortlong big = 65537;long verybig = 12345678908642;//C也可以使用前缀h来表示short类型。