c语言第二章课后习题答案 下载本文

}

scanf(\ /*注意:输入的两个字符之间要用逗号隔开*/ i= c1

printf(\

5. 用C赋值语句表示以下计算式:

1)Area=?r2+2?rh

2m1m2?g2)Torque=

m1?m2

3)Side=a2?b2?2abcos(x)

(velocity)24)Energy=mass[acceleration×height+]

2【参考答案】

1)Area=PI*r*r+2*PI*r*h

2)Torque=((2*m1*m2)/(m1+m2))*g 3)Side=sqrt(a*a+b*b-2*a*b*cos(x))

4)Energy=mass(acceleration*height+velocity*velocity/2) 转换成程序: #include \#define PI 3.1415926 void main() { float r,h,Area; printf(\ scanf(\ pirntf(\ scanf(\ Area=PI*r*r+2*PI*r*h; printf(\} 2)

#include \#define g 9.8 void main()

{ float m1,m2,Torque; printf(\

scanf(\ pirntf(\ scanf(\

Torque=((2*m1*m2)/(m1+m2))*g; printf(\} 3)

#include \#include \void main() { float a,b,c,Side; printf(\ scanf(\ printf(\ scanf(\ printf(\ scanf(\

Side=sqrt(a*a+b*b-2*a*b*cos(x)); printf(\} 4)

#include \void main()

{ float mass,acceleration,height,velocity; printf(\ scanf(\

printf(\ scanf(\ printf(\ scanf(\ printf(\ scanf(\

Energy=mass(acceleration*height+velocity*velocity/2); printf(\