(吉顺如主编 曾祥绪、陶恂副主编) C程序设计教程与实验 课后习题答案
欢迎大家提出答案不合理的地方哦!一起加油呀!
目录
第一章 C语言程序设计概述
- 选择题
1-5 ACDBC 6-10 CDCBA - 填空题
(1)1 函数体
(2)main() mian()
(3)编译 目标
(4).c .obj .exe
(5)缩进 无影响 /* */ //
(6)(1111011)2 (173)8 (7D)16
(7)53
(8)110100101 - 编程题
(1)
#include <stdio.h>
int main()
{
printf("班级\n姓名\n学号\n");
return 0;
}
(2)
#include <stdio.h>
int main(){
int a,b,add,subtract,multiply;
float divide;
printf("请输入两个正整数:");
scanf("%d%d",&a,&b);
add = a+b;
subtract = a-b;
multiply = a*b;
divide =(float) a/b;
printf(" %d+%d=%d\n %d-%d=%d\n %d*%d=%d\n %d/%d=%.2f\n",a,b,add,a,b,subtract,a,b,multiply,a,b,divide);
return 0;
}
第二章 顺序结构程序设计
-
选择题
1-5 DDBCA 6-10BBBDD -
填空题
(1)5.5
(2)14.2 20
(3)x%1010+x/10
(4)sin(sqrt(xx))/(a*b)
(5)3
(6)3
(7)有穷、确定、可行
(8)97,g
(9)%f%f &x,&y
(10)16.00 -
编程题
(1)
#include <stdio.h>
# include <math.h>
int main(){
float a ,b,x,j;
printf("请输入两个数值:");
scanf("%f%f",&a,&b);
x = (a*a + b*b)/sqrt(3.00/(a+b));
printf("%5.3f\n",x);
return 0;
}
(2)
#include <stdio.h>
int main(){
float a, b, h;
float s = 0.00;
printf("请输入三个数:");
scanf("%f%f%f",&a,&b,&h);
// s =(1/2)*(a+b)*h;//当写成1/2时算出来为0.5但是只写0
s =0.5*(a+b)*h;
printf("%5.2f\n",s);
return 0;
}
第三章 选择结构程序设计
- 选择题
1-5 BBCAC 6-10 CDBCC
解析:10、先计算关系运算符(==)再计算赋值运算符(=),关系运算符的运算结果均为(“真"或"假”),故a = 1,b = 0; - 填空题
(1)1
(2)x%2== 0
(3)1
(4)(year%= = 0 && year %100 != 0) || (year%400 == 0)
(5)A
(6)x < 0 || (x > 10 && x < 50)
(7)5 3 2
(8)$
(9)(1)2 (2)3 CC a = 2,b=2,c=4
(10)a = 2,b = 3 - 编程题
(1)
#include <stdio.h>
# include <math.h>
int main()
{
float x,y;
printf("请输入x的值:");
scanf("%f",&x);
if(x<4){
y = (x+7)/(2*x-1);
printf("y=%.2f\n",y);
} else if(x>=4&&x<70){
y = 3*x*x+5;
printf("y=%.2f\n",y);
}else if(x>=70){
y = x-sqrt(4*x-1);
printf("y=%.2f\n",y);
}
return 0;
}
(2)
#include <stdio.h>
#include <math.h>
int main()
{
float a,b,c,s,area;
printf("请输入三角形的三条边:");
scanf("%f%f%f",&a,&b,&c);
s = (a+b+c)/2;
if