C语言程序设计课后习题答案------吉林大学版--------武爱平
- 格式:doc
- 大小:107.00 KB
- 文档页数:59
第一章
1.选择题
(1)B(2)C(3)C(4)D(5)B(6)D(7)D(8)C
2.填空题
(1)函数
一个主函数
函数
(2)/*
*/
(3)连接
3.程序设计题
(1)
#include
main()
{
printf(" *\n");
printf("* S *\n");
printf(" *\n");
}
(2)
#include
main()
{
printf("******************\n");
printf("Your are welcome!\n");
printf("------------------\n");
}
第二章
1.选择题
(1)D(2)D(3)B(4)C(5)B(6)C(7)C(8)C(9)D(10)C(11)A(12)B(13)A(14)C(15)A(16)B(17)A(18)B(19)C(20)A(21)C(22)C 2.填空题
(1)①9
②-2
③62
④44.8
(2)
①10.5
②73.1
③7
④7.2
(3)"%6x"
"%o"
"%3c"
"%10.3f"
"%8s"
(4)int a,b,c;
&a,&b,&c
temp=a;
c=temp;
(5)49
61
31
1
3.程序设计题
(1)
#include
main()
{
double a,b,c,d;
double aver=0.0;
printf("\nPlease input four double number:");
scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
aver=(a+b+c+d)/4;
printf("\nThe average of the four double number is %lf",aver);
}
(2)
#include
#define PI 3.14159
main()
{
double r;
double area=0,len=0;
printf("\nPlease input r:");
scanf("%lf",&r);
area=PI*r*r;
len=2*PI*r;
printf("\n area=%lf,length=%lf",area,len);
}
(3)
#include
main()
{
float i,s;
printf("\nPlease input data:");
scanf("%f%f",&i,&s);
s=s*(1+i);
printf("\nI have %.2f yuan after one year.",s);
}
第三章
1、选择题
(1)C(2)C(3)A(4)C(5)D(6)A(7)C(8)A(9)B(10)D 2、填空题
(1)&m,&n
m=n;
n=temp;
m,n
(2)①5 5 4
②5 5 4
③3 3 4
(3)9
i+1
"%d",i
printf("\n");
(4)73
-543
93201
3、程序设计题
(1)
#include
#include
main()
{
double a,b,c,d,det,a_2,real,imag,x1,x2;
printf("Please enter a,b,c:");
scanf("%lf%lf%lf",&a,&b,&c);
if(a==0&&b==0)
printf("No root!\n");
else if(a==0)
printf("Line equation root is %.2lf\n",-c/b);
else
{
d=b*b-4*a*c;
det=sqrt(fabs(d));
a_2=2*a;
if(d<0)
{
real=-b/a_2;
imag=det/a_2;
printf("The two root are:\n%.2lf+%.2lfi\n",real,imag);
printf("and\n%.2lf-%.2lfi\n",real,imag);
}
else if(d==0)
printf("Single real root is %.2lf:\n",-b/a_2);
else
{
x1=-b/(a_2)+det/a_2;
x2=-b/(a_2)+det/a_2;
printf("The two real roots are :\n%.2lf\n
and\n %.2lf\n",x1,x2);
}
}
}
(2)
#include
main()