华中科技大学实用标准C语言程序设计及指导应用习题问题详解

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第二章

一.选择题

1.C

2.B D

3.A

4.A

5. D

6.C

7.D

8.C

9.A 10.D 11.B 12.D 13.C 14.D 15.A

16.B 17.A 18.B 100011 001111

二.判断题

1.错

2.错

3.错

4.错

三.填空题

1. B 66

2. n1=%d\nn2=%d\n

3. 0

四.计算

1

(1)x|y = 0x002f

(2)x^y = 0x0026

(3)x&y = 0x0009;

(4)~x+~y = 0xffc6

(5)x<<=3 0x0068

(6)y>>=4 0x0002

2

(1) 6

(2)50

(3) 1

(4)–16

(5) 1

(6)20

3

(1)0

(2) 1

(3) 1

(4) 4

(5)8

(6) 1

4

(1)12

(2)0

(3) 1

(4)27

(6) 6

(7)24

(8)27

(9)–29

5

(1)0

(2) 1

(3) 1

(4)–3

(5) 2

五.程序分析题

程序1

b=20 a=3600

程序2

第三章

一.填空题

1.s=6

2.96

3.(1) scanf("%c",&c);

(2) c-32 更好的答案:c-('a'-'A')

2.1

main()

{

int a,b;

printf("please input a & b:");

scanf("%d%d",&a,&b);

printf("\nmax is %d\n",(a>b)?a:b);

}

2.2

int max(int x,int y);

main()

{

int a,b,c,max;

printf("please input a & b & c:");

scanf("%d%d%d",&a,&b,&c);

max=a>b?a:b;

max=c>max?c:max;

printf("\nmax is %d\n",max);

}

2.3

{

int i=0,sum=0;

while(i<=100)

{

sum+=i;

i++;

}

printf("1+2+3+......+100=%d\n",sum);

}

2.4

main()

{

int i;

int a=10,b=-3;

int c;

printf("%6d%6d",a,b);

for(i=2;i<10;i++)

{

c=3*b+a;

printf("%6d",c);

a=b;

b=c;

}

printf("\n");

}

2.5

main()

{

int i;

while(1)

{

printf("please input a data(0:exit):");

scanf("%d",&i);

if(i==0)

break;

if(i%2==0)

printf("the data %d is a even number.\n",i);

else

printf("the data %d is a odd number.\n",i); }

}

2.6

#include

main()

{

int i;

int a=8,b=1;

int sum=0;

for(i=0;i<10;i++)

{

b+=3;

sum += a;

a+=b;

printf("a%8d b:%8d\n",a,b);

}

printf("The Sum Of Is:%d\n",sum);

}

2.7

#include

main()

{

float x,y;

printf("please input x:");

scanf("%f",&x);

if(x<1.0)

y=x;

else if(x<10)

y=2*x-1;

else

y=3*x-11;

printf("y=%f\n",y);

}

2.8

#include

main()

{

long a,i,b,a1;

while(1)

{

printf("please input data(1-99999):");

scanf("%ld",&a);

printf("a:%ld\n",a);

if(a<=0||a>=100000)

break;

i=0;

a1=0;

相关文档
最新文档