2.6
1)
please input 3 sides of one triangle: 6,6,8
a= 6.00,b= 6.00,c= 8.00 area of triangle is 17.88854
2)
该程序计算三角形的面积
前后分为三部分:输入,处理,输出。 2.7 In main(): Enter two numbers: 3 8
Calling add():
In add(),received 3 and 8 and return 11
Back in main(): c was set to 11
Exiting... 3.1 (1)
sqrt(pow(sin(x),2.5))
(2)
(a*x+(a+x)/(4*a))/2
(3)
pow(c,x*x)/sqrt(2*M_PI) //M_PI为BC中math.h中的圆周率常数 3.2 13.7 2.5 9 3.3 (1) a1=1 (2) 1.1 (3)
a2=1
2,0.0 (4) 20 5.4
Main--x=5,y=1,n=1 Func--x=6,y=21,n=11 Main--x=5,y=1,n=11 Func--x=8,y=31,n=21 5.6
double poly(int n, double) {
if(n==0) return 1; if(n==0) return x;
return ((2*n-1)*x*poly(n-1,x)-(n-1)*poly(n-2,x))/n; } 6.1 //6_1 (1)
//file1.cpp int x=1; int func() { //... }
//file2.cpp extern int x; int func(); void g() {
x=func(); }
//file3.cpp
extern int x=2; //error: extern int变量若有赋值,则成定义 int g(); //error: 函数声明与前面不一致 void main() {
x=g();
//... } (2)
//file1.cpp int x=5; int y=8; extern int z;
//file2.cpp
int x; //error: int x;重复定义
extern double y; //error: y同一名字不同类型定义 extern int z; //error: z只有声明,却无定义 6.2 25 10.4 //10_4 (1)
见10_4_1.cpp (2) data? 3 data? 5 data? 7 data? 6 data? 4 data? 8 data? -3 3 5 7 6 4 8
(3)
见10_4_3 12.1
Constructing normally. Constructing with a number: 20 Display a number: 1 Display a number: 20 Destructing.
Destructing. 12.2 //12_2
//见employee.h // employee.cpp 12.3 //12_3.txt
//见employ.h // employ.cpp //13_1.txt
物质 有机物 生物
动物
哺乳动物 人类
猿类 猫科类
... 卵生动物 植物 非生物 无机物 //13_2
Ignore //14_1
Multi[0] is:0 Multi[1] is:1 Multi[2] is:4 Multi[3] is:9 Multi[4] is:16 Multi[5] is:25 Multi[6] is:36 Multi[7] is:49 Multi[8] is:64 Multi[9] is:81 Destroying..9 Destroying..8

