2024年1月13日发(作者:)
第1章
1.选择题
(1) C (2) B (3) D
2.填空题
(1)main (2) main (3) 有穷性、确定性、有零个或多个输入、有一个或多个输出、有效性
(4) 顺序、分支和循环(5) 自顶向下,逐步细化、模块化设计、结构化编码
第2章
1.选择题
BBCDA DDBBA BBDCB
2、填空题
(1) 数字、字母、下划线 (2)0 (3) 4、8 (4) (a+b)*c/(a-b) (5) -60 (6)-16
(7)3 (8)6、4、2 (9)0 (10)10、6 (11)5.500000 (12) 12、4
(13)double (14) 0 (15)16 (16)6.6
3、编程题
(1)
main()
{
printf("int:%5dn"
"float:%5dn"
"char:%5dn"
"double:%5dn"
"long:%5dn",
sizeof(int),+-
sizeof(float),
sizeof(char),
sizeof(double),
sizeof(long));
}
(2)
#define RAT 1.60934
main()
{
float k=0.0;
printf("input the km:");
scanf("%f",&k);
printf("nmile:%f",k*RAT);
}
第3章
1.选择题
(1) ~(10):DDCDCDCDBC
2.解析题
(1) x=170,x=ㄩㄩㄩ170,x=ㄩㄩㄩ252, x=ㄩㄩㄩ170
x=170,x=170ㄩㄩㄩ,x=ㄩㄩㄩ170,x=%6d
a=513.789185,a=ㄩㄩ513.79,a=513.78918457,a=513.78918457
(2) a=3ㄩb=7x=8.5ㄩy=71.82c1=Aㄩc2=a
3.编程题
(1)
main()
{
int x,y;
scanf("%d%d",&x,&y);
printf("商数=%d,余数=%d",x/y,x%y);
system("pause");
}
(2)
main()
{
double x,y,z,avg;
scanf("%lf%lf%lf",&x,&y,&z);
avg=(x+y+z)/3;
printf("%.1lf",avg,avg);
system("pause");
}
第4章
1.选择题
(1)~(10) CCAADCCABD
2.填空题
(1) ch>='A' && ch<='Z' ch=ch-32
(2) x<=10 && x>2 x<=2 && x>-1 y=-1
(3) a+b>c && a+c>b && b+c>a a==b&&a==c a==b || a==c || b==c
(4) mark/10 k=1 case 9
(5) x<0 c=x/10 y!=-2
3.编程题
(1)
#include
main()
{
int x;
printf("please input a number:");
scanf("%d",&x);
if(x%2==0) printf("x is a even number");
else printf("x is a odd number");
}
(2)
#include
main()
{
int x,y;
printf("please input a number£o");
scanf("%d",&x);
if(x<=-5) printf("the number is error");
else if(x<0) {y=x; printf("%d",y);}
else if(x==0) {y=x-1;printf("%d",y);}
else if(x<10) {y=x+1;printf("%d",y);}
else printf("the number is error");
}
(3)
#include
main()
{ int a,m;
printf("please input a number:");
scanf("%d",&a);
switch(a/10)
{ case 0:
case 1:
case 2:m=1;break;
case 3:m=2;break;
case 4:m=3;break;
case 5:m=4;break;
default:m=5;break;
}
printf("%d",m);
}
(4)
#include
main()
{
float price,tax;
printf("please input the price of product:");
scanf("%f",&price);
if(price>10000) tax=price*0.05;
else if(price>5000) tax=price*0.03;
else if(price>1000) tax=price*0.02;
else tax=0;
printf("%f",tax);
}
(5)
#include
main()
{
float score;
printf("please input the score of student:");
scanf("%f",&score);
if(score>=85) printf("VERY GOOD");
else if(score>=60) printf("GOOD");
else printf("BAD");
}
第5章
1.选择题
(1)d (2) c (3)a (4)d (5)a (6)d (7)d (8)b (9)d (10)b
(11)c (12)b (13)d (14)a (15)c
2.填空题
(1) ==0 m=m/k k++ (2) 5 4 6 (3) 3*i-2
(4) -= *= (5) 8 5 2 (6) j++ i%j==0 j>=i
(7)sum 3.改错题 (1) 第一处改正: For改为for 第二处改正: ave=sum/4改为ave=sum/4.0 (2) 第一处改正: j<=9 第二处改正: m=100*i+10*j+k 3.编程题 (1) #include main() { int s; float n,t,sum; t=1; sum=0; n=1; s=1.0; while(n<=100) { sum=sum+t; n=n+1; s=-s; t=s/n; } printf("sum=%10.6fn",sum); } (2) 利用辗除法,直到b为0为止 main() { int p,r,n,m,temp; printf("input two integer n,m:"); scanf("%d,%d",&n,&m); if(n { temp=n; n=m; m=temp; } p=n*m; while(m!=0) { r=n%m; n=m; m=r; } printf("greatest common divisor is:%dn",n); //最大公约数 printf("lease common multiple is:%dn",p/n); //最小公倍数 } (3) 采取逆向思维的方法,从后往前推断。 main() { int day,x1,x2; day=9; x2=1; while(day>0) { x1=(x2+1)*2; /*第一天的桃子数是第2天桃子数加1后的2倍*/ x2=x1; day--; } printf("the total is %dn",x1); } (4) #include main() { int i; long int n=1; for(i=1;i<=10;i++) { n=n*i; printf(i%5==0?"%2d!=%-10ldn":"%2d!=%-10ld",i,n); } } (5) main() { int m,s,i; for(m=2;m<1000;m++) { s=0; for(i=1;i if((m%i)==0) s=s+i; if(s==m) { printf("%d its factors are ",m); for(i=1;i if(m%i==0) printf("%d,",i); printf("n"); } } } (6) #include main() { int n,i,j; scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n+i-1;j++) if(j<=n-i) printf(" "); else printf("*"); printf("n"); } } (7) #include main() { float x0,x1,x2,fx0,fx1,fx2; do { printf("Enter x1 & x2:"); scanf("%f,%f",&x1,&x2); fx1=x1*((2*x1-4)*x1+3)-6; fx2=x2*((2*x2-4)*x2+3)-6; }while(fx1*fx2>0); do { x0=(x1+x2)/2; fx0=x0*((2*x0-4)*x0+3)-6; if((fx0*fx1)<0) { x2=x0; fx2=fx0; } else { x1=x0; fx1=fx0; } }while(fabs(fx0)>=1e-5); printf("x=%6.2fn",x0); } 第6章 1.选择题 CCDCC AADBD 2. 写出程序的运行结果 (1) sum=6 (2) Max=9,row=1,col=0 (3) 0 1 0 2 1 0 3 2 1 0 (4) -5 3、填空 (1)i=j=k=0 、 i<4 、j<5、 (2) s 、 s[0],s[1] 、str,s[1]、s[2],str 4、编程题 (1) #include main() { int a[12],count=0,i; randomize(); for (i=0;i<12;i++) a=5+random(11); for(i=0;i<12;i++) { printf("%5d",a); count++; if(count%4==0)printf("n") ; } getch(); } (2) main() { int a[5]={2,23,43,77,33}; int max,min,i; long sum=0L; int count=0; float av; max=min=a[0]; for(i=0;i<5;i++) { sum+=a; if(a>max)max=a; if(a } av=(float)sum/5; for(i=0;i<5;i++) if(a>av)count++; printf("max:%dnmin:%dnav:%fncount:%d",max,min,av,count); getch(); } (3) main() { int score[30]={61,62,63,64,65,66,67,68,69,70, 71,72,73,74,75,76,77,78,79,80, 81,85,89,90,33,44,55,91,92,93}; int i,count90=0,count80=0,count70=0,count60=0; for(i=0;i<30;i++) { printf("intput NO. %d student's score:",i+1); scanf("%d",score+i); } for(i=0;i<30;i++) { if(score>=90) { count90++; count80++; count70++; count60++; } else if(score>=80) { count80++; count70++; count60++; } else if(score>=70) { count70++; count60++; } else if(score>=60) { count60++; } } printf("0~60:%dn60~70:%dn70~80:%dn80~90:%dn90~100:%d",30-count60,count60-count70,count70-count80,count80-count90,count90); printf("n60 or higher:%dn70 or higher:%dn80 or higher:%dn90 or higher:%dn",count60,count70,count80,count90); getch(); } (4) 1、 main() { char a[45]; int i,j,k; for(i=0;i<45;i++)a=' '; for(i=0;i<5;i++) { for(j=0;j a[9*i+j]=' '; for(k=0;k<5;k++) a[9*i+j+k]='*'; } j=0; for(i=0;i<45;i++) { printf("%c",a); j++; if(j%9==0)printf("n"); } getch(); } 2、 main() { char a[5][9]; int i,j,k; for(i=0;i<5;i++) for(j=0;j<9;j++) a[j]=' '; for(i=0;i<5;i++) { for(j=0;j a[j]=' '; for(k=0;k<5;k++) a[j+k]='*'; } for(i=0;i<5;i++) { for(j=0;j<9;j++) printf("%c",a[j]); printf("n"); } getch(); }
发布者:admin,转转请注明出处:http://www.yc00.com/web/1705101270a1393321.html
评论列表(0条)