内容发布更新时间 : 2025/6/21 3:11:00星期一 下面是文章的全部内容请认真阅读。
五、把下列数学算式或不等式表示成C++表达式
1. 2x(1+x2/3) 2. (1+ex)/(1-ex) 3. (-b+(b2-4ac)1/2)/2a 4. 1/(3xln(2x+k))
5. sin3(x+π/4)/(3+cos3(x-π/4)) 6. 1/7(1+ex+1) n 7. 0<=x<=20 8. ax-by!=c 9. 4x+7y-2=3ab
10. |2x2+1|/|3x+2|<-5同时3x+2!=0 11. age>=55或者pay>=820
12. place=”江苏”同时sex=”女”
13. ‘a’<=ch<=’z’或者’A’<=ch<=’Z’
14. s[0]=’0’同时(s[1]=’x’或者s[1]=’X’)
六、写出下列每个程序运行后的输出结果并自行上机验证
1. #include
enum race{Black,White,Yellow}; void main() {
race ra;
ra=Black;cout<
2. #include
#define PI 3.14159 const int R=10
void main() {
double p,s;
p=2*R*PI;
cout<<”p=”<
3. #include
void main() {
int i=0,j=1,k;
k=i+=j;
cout<
cout<
cout<
4. #include
void main() {
cout<
cout<
5. #include
const int w=30; void main()
’; {
int x,y;
x=w<<2;y=w>>2;
cout<
cout<
cout<
6. #include
void main() {
int x=10,y=-1;
cout<<((x>y)&&(y<0))<<’ ’; cout<<((x>y)||(y<0))<<’ ’; cout<<((x<=y)&&(y>=0))<<’ ’; cout<<((x<=y)||(y>=0))<<’ ’; cout<<((x==y)&&y)<<’ ’; cout<<((x==y)||y)<<’ ’; }
7. #include
void main() {
int x=5,y=10,k;
(k=x)+=y;cout<
cout<
}
8. #include
#include
double x=15.72;
double y,z;
y=ceil(x);z=floor(x);
cout<
七、编写下列程序
1. 已知一个三角形中三条边的长度分别为a,b和c,利用计算公式(s(s-a)(s-b)(s-c))1/2 求出三角形的面积,其中s=(a+b+c)/2,假定a,b和c的值由键盘输入,并确保任何两边的长度大于第三条边。
2. 假定一所大学2001年招生人数为3000人,若以后每年平均比上一年计划扩招10%,则2006年将计划招生多少人?
3. 已知有4个整数为a,b,c,d,试计算出它们的算术平均值和几何平均值。 4. 已知x=2a/2(a+b)sina,y=2b/3(a+b)cosb,试根据从键盘上输入的a和b的值分别计算出x和y的值。
八、上机实验题
1. 让计算机随机出10道两位整数加法题供用户计算,每道题10分,计算完成后打印出得分。 #include
#include