Title: Module5: Performing Administrative Tasks
1???
?????
2 ??????
C?????? ---------- http//www.tup.tsinghua.edu
.cn/
3 ????
- 9.1 ???
- 9.2 ????
- 9.3 ????
4 ????
- ?C?????????????,????C?????????,???????
- ??,?????define?????????PI?
- define PI 3.14159
- ????????????????????????????????,???????????????
???? ??
5 ????
C??????????????? (1)??? (2)????
(3)???? ???????????????????????????????????C???
??,?????????? ?? define
include
69.1 ???
9.1.1 ???????? ??????????????????????????????
???? define ??? ???
7 9.1 ???
?????? input a number 2 ? y29
? ??????????? include ltstdio.hgt define M
(xx2x-1) void main() int x,y
printf("input a number") scanf("d",x)
y xM2M1 printf("yd\n",y)
??????????????? yx(xx2x-1)2(xx2x-1)
1 /?yx34x23x-1/
8 8.1 ???
??,????????? difine M
xx2x-1 ???????????? Yxxx2x-12xx2
x-11 /????y x32x24x-1/
9 8.1 ???
????????????? (1)????????(??)????????,?????????
??????,??????????,???????????,?????,???????,??????
????????????,???????????????????
(2)??????????,????????,???????????????
(3)???????????,???????????????????????????,???und
ef???
10 8.1 ???
(4)????????????????,??????????????P206?9.2??L
(5)???????,?????????????????????????????????????
?? define PI 3.1415926 define S
PIyy / PI???????/ ???
printf("f",S) ???????
printf("f",3.1415926yy)
11(6)????????????,???????????????????
(7)???????????,?????? ?? define INT
int ??????INT????? INT a10,
body5 (8)????????????,????????????????????,??
??????????????,????????????
12? ??????????? define PR printf define D "d
" define F "f\n" include ltstdio.hgt void
main() int a012, c-8, e11 float b3.8,
d9.7, f21.08 PR(D F,a,b) PR(D F,c,d)
PR(D F,e,f)
?????? 10 3.800000 -8 9.700000 11 21.000000
??????????????????????,???????????,??????,????
????
139.1.2 ??????? 1. ?????????? ???????????
define ??(???) ???
????????????? ??(???)
?? define N(x,y) 3xyy /??????/
kN(7,9) /????????????k 3799/
14?????? input two numbers 23 8? max23
? ????????? include ltstdio.hgt define MAX(a,b)
(agtb)?ab void main() int x,y,max
printf("input two numbers") scanf("dd",x,y)
maxMAX(x,y) printf("maxd\n",max)
maxMAX(x,y) ,?? x?y?????a?b? ???????? max(xgty)?
xy
152. ???????????? ????????????????? (1)??????,???
????????????? ?? define MAX(a,b) (agtb)?ab
??define MAX (a,b) (agtb)?ab
(2)????????????,???????????????
16? ???????????????? include ltstdio.hgt define
S1(y) (y)(y) void main() int a,sq
printf("input a number ") scanf("d",a)
sqS1(a1) printf("sqd\n",sq)
?????? input a number 6 ? sq49
17 8.1 ???
(3)?????,??????????????????????
P208
(4)??????????????,?????,??????????????
?9.4???????????????
18void main() float r,l,s,v
scanf("f",r) l2 3.1415926 r s
3.1415926 rr v4.0/3.0 3.1415926
rrr printf("r6.2f,l6.2f,s6.2f,v6
.2f\n",r,l,s,v)
- include ltstdio.hgt
- define PI 3.1415926
- define CIRCLE(R,L,S,V) L2PIRSPIRRV4.0/3.
0PIRRR - void main()
- float r,l,s,v
- scanf("f",r)
- CIRCLE(r,l,s,v)
- printf("r6.2f,l6.2f,s6.2f,v6.2f\n",r
,l,s,v) -
19- 3. ???????????
- (1) ?????,??????????,??????????????????????????
- (2) ??????????????,??????????????????????????,?
???????????,?????????,?????????? - (3) ???????????????????????,????????,????????,?
?????????????????,?????????????? - (4) ?????????????,??????????????(?9.4 )
20 (5) ???????,????????,?????????????,????????????
?? (6) ?????????,??????????????????(???????????
?????)?
?? ?????????,?????????,???????????????,?????
?????????????????????
219.2 ????
??????????????????????????????????,???????????
????? ????include ??? ?
include lt???gt
???????????????????????,????????????
include ltstdio.hgt include ltmath.hgt
229.2 ????
????
?? ????????????????????,??????????????,??????????
?????file2.c???????,?????????,???????????,??????(.
obj)????????????????????,??????????
239.2 ????
??????????????? (1)??????????????????
?????(?ltstdio.hgt??)?,?????C??????????????????,????
??????????????????????????
?????(?stdio.h??)?,???????????????????,????,????
?????????????????????????????????
249.2 ????
(2)??include?????????????,?????????,?????include??
? (3)????????,??????????????????????
??????????,?????????????
25 9.3 ????
????????,?????????????,????????????????
1.???????3???
(1)ifdef ??? ???1 else ???2
endif
(2)ifndef ??? ???1 else ???2
endif
(3) if ??? ???1 else ???2
endif
26 9.3 ????
2. ?????? ? ????ifdef????
?????? Hello Ted RALPH not defined
include "stdio.h" define TED 10 void main ()
ifdef TED printf("Hello Ted\n") /
?????TED,??????? / else printf("Hello
anyone\n")/ ??????TED,??????? / endif
ifndef RALPH printf ("RALPH not defined\n")/
??????RALPH,????? / endif
27? ????if???? include "stdio.h" define PI
3.14159 define R 1 void main() float c,r,s
printf ("input a number ") scanf("f",c)
if R rPIcc printf("area of round is
f\n",r) else scc printf("area of
square is f\n",s) endif
?????? input a number5? area of round is
78.539749
28THE END
THE END
THE END