c语言程序设计教程北京邮电大学出版社答案,C语言程序设计教程习题答案~主审郭浩志北京邮电大学出版社.doc...

C语言程序设计教程习题答案~主审郭浩志北京邮电大学出版社

习题一

1.自然语言,专用工具,部分常用的算法

2.头文件,用户函数说明部分;全局变量定义;主函数;若干用户自己编写的函数。例1.1

3.①C语言具有结构语言的特点,程序之间很容易实现段的共享;

②C语言的主要结构成分为函数,函数可以再程序中被定义完成独立的任务,独立地编译成代码,以实现程序的模块化;

③C语言运算符丰富,运算符包含的范围很广;

④C语言数据类型丰富;

⑤C语言允许直接访问物理地址,即可直接对硬件进行操作,实现汇编语言的大部分功能;

⑥C语言语法限制不太严格,程序设计自由度大,这样使C语言能够减少对程序员的约束;

⑦用C语言编程,生成的目标代码质量高,程序执行效率高;

⑧等等。

合法标识符:AB12leed_3EF3_3PASif

XYZ43K2_762

F2:将当前编辑器中文件存盘; F10:调用主菜单; F4:程序运行到光标所在行; Ctrl+F9:当前编辑环境下,进行编译、连接且运行程序; Alt+F5:将窗口切换到DOS下,查看程序运行结果。

Vc++

.

7.主函数

标识符:由字母、数字以及下划线组成,并且只能由字母或者下划线开头;

关键字:关键字不能作为变量或函数名来使用,用户只能根据系统的规定使用它们。

习题二

’\’,“\”,“ab\n”

2.(1)#include

void main()

{int x,y,z,aver;

x=7;

y=z=5;

aver=(x+y+z)/3;

printf("aver=%d\n",aver);

}

结果:aver=3

(2)

#include

void main()

{char c1='a',c2='b',c3='c';

int a=3.5,b='A';

printf("a=%db=%c\n",a,b);

printf("a%cb%c\bc%c\tabc\n",c1,c2,c3);

}

3.

int99104665568-1char‘c’‘h’‘B’‘7’‘D’unsigned int99104665568float99.00104.0066.0055.7868.00-1.00long int99104665568-14,(1)8,10,9,10;

(2)3,1,0,0;

a=11,b=19,c=30,d=1;

(1).0(2).0(3)9.5;(4)40(5).10(6).10(7).‘a’(8).14,30,(2.2)(9).4.5(10).1(11).0(12).10(13).5

(1)

取x的绝对值

max = a

-60

D

习题三

格式说明符不对,应把%d换位%f。

|1234 1234 |

ff,10

1,3,1

按字符串的实际疮毒输出;在右端补空格

6. scanf("%d,%d,%c,%c",&a1,&a2,&c1,&c2);

7.#include

main()

{int a,b;

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

printf("a+b=%d\na-b=%d\na*b=%d\n(float)a/b=%d\na%b=%d\n",a+b,a-b,a*b,a/b,(float)a/b,a%b);

}

8.#include

main()

{float r,l,s;

scanf("%f",&r);

l=2*3.14*r;

s=3.14*r*r;

printf("l=%f\ns=%f\n",l,s);

}

9.#include

main()

{int x,y;

int a,b,c;

scanf("x=%d",&x);

a=x/100;

b=(x-a*100)/10;

c=x-a*100-b*10;

y=c*100+b*10+a;

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

}

10.

#include

main()

{ int a,b,c,d,e,f,g;

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

printf("a=%d,b=%d,c=%d\n",a,b,c);

e=a%2; f=b%2; g=c%2; d=e+f+g;

if(d==2) printf("YES\n");

else printf("NO\n");

return 0;

}

11.#include

main()

{int ch;

ch=getchar();

putchar

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
期末作业要求如下: Write a program that will help elementary school pupils practice math. a) The program will first ask the user for his/her ID number (including two letters & 4 digits), e.g. Please input your four digit ID no: AB1234 The program should have input validation. Then the program prompts three choices: (1) Start a test (2) Check scores (3) Exit Test: the program will give 10 math problems, e.g.: 12 * 3 = 36 48 + 32 = 80 … 56 / 28 = 2 Note: i) Pupils will answer each problem before the next one is given. ii) The problems should include addition, subtraction, multiplication and division. They are randomly generated. iii) Randomly generates numbers for problems. However, must ensure that both the problem and the result are no larger than two digits. The problem and the result should be greater than or equal to zero. The divisor cannot be zero. iv) After ten problems are finished, record the time used by the student to do the ten problems. v) Gives a score to each student. Saves this student’s ID, his/her score and the time used into a file named ‘record.txt’. vi) Print the following information on the screen: Prob. | Correct Answ. | Ur Answ c) Check scores: Searches the file ‘record.txt’ and lists all the historical scores for this student, e.g.: Your previous records are: AB1234 80 150 seconds AB1234 50 182 seconds AB1234 90 98 seconds You will be marked based on your program’s: (1) Correctiveness (2) Readability (3) Robustness (4) Conciseness 目前本人的程序可以直接使用,并完全满足要求。还是建议学弟学妹在字里行间多多理解,争取自己写出漂亮的代码! 向本人在完成此作业过程中参考的代码表示衷心的感谢!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值