C ?????????????,?????????????????????? - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

C ?????????????,??????????????????????

Description:

Title: Last modified by: zongmk Created Date: 8/9/2000 8:19:19 AM Document presentation format: Other titles – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 36
Provided by: educ5219
Category:
Tags:

less

Transcript and Presenter's Notes

Title: C ?????????????,??????????????????????


1
??? ??
  • 9.1 ?????
  • 9.2 ?????
  • 9.3 ??????
  • 9.4 ?????????
  • 9.5 ?????

2
??
  • C?????????????,??????????????????????

3
9.1 ?????
  • ????????,??????,???????????(??)??????????????????
    ??????,?????????????????
  • ???????,????????,???????,?????????????????????
    ?
  • ? ????? ????????

4
  • ?????????
  • int someInt
  • int rIntsomeInt
  • ??
  • (1)?????,??????,?????,????????????
  • (2)??????,?????
  • (3)????????????????,??????????????,???????????,???
    ?????
  • (4)????????????,??????????

5
  • ?1????????
  • //ch9_1.cpp
  • includeltiostream.hgt
  • void main()
  • int intOne
  • int rIntintOne
  • intOne5
  • coutltltintOneltltintOneltltendl
  • coutltltrIntltltrIntltlt endl
  • rInt7
  • coutltltintOneltltintOneltlt endl
  • coutltltrIntltltrIntltlt endl

6
9.1 ?????(?1)
  • ?1 (?)
  • ??
  • intOne5
  • rInt5
  • intOne7
  • rInt7

7
  • ????????????????
  • ???????????????????????????,???????
  • (1)??????????????,?????????
  • ?int rIntintone
  • (2)???????????????
  • ?int ipintone
  • coutltlt ip
  • (3)???????,????????????????????

8
??? ??
  • 9.1 ?????
  • 9.2 ?????
  • 9.3 ??????
  • 9.4 ?????????
  • 9.5 ?????

9
9.2 ?????
  • ???????????,???????????????

10
  • ?1???????
  • //ch9_2.cpp
  • includeltiostream.hgt
  • void main()
  • int intOne
  • int rIntintOne
  • intOne5
  • coutltltintOneltltintOneltltendl
  • coutltltrIntltltrIntltltendl
  • coutltltintOneltltintOneltltendl
  • coutltltrIntltltrIntltltendl

11
9.2 ?????(?1)
  • ?1 (?)
  • ??
  • intOne5
  • rInt5
  • intOne00F35300
  • rInt00F35300

12
9.2 ?????(?2)
  • ??
  • (1)C???????????????,????????????????,????????
  • (2)???????,???????????,??????

13
  • ?2???????
  • //ch9_3.cpp
  • includeltiostream.hgt
  • void main()
  • int intOne
  • int rIntintOne
  • intOne5
  • coutltltintOneltltintOneltltendl
  • coutltltrIntltltrIntltltendl
  • coutltltintOneltltintOneltltendl
  • coutltltrIntltltrIntltltendl

14
  • ?2 (?1)
  • int intTwo8
  • rIntintTwo
  • coutltltintoneltltintOneltltendl
  • coutltltintTwoltltintTwoltltendl
  • coutltltrIntltltrIntltltendl
  • coutltltintOneltltintOneltltendl
  • coutltltintTwoltltintTwoltltendl
  • coutltltrIntltltrIntltltendl

15
  • ?2 (?2)
  • ??
  • intOne5
  • rInt5
  • intOne0110F150
  • rInt0110F150
  • intOne8
  • intTwo8
  • rInt8
  • intOne0110F150
  • intTwo0110F14E
  • rInt0110F150

16
9.2 ?????(?3)
  • ??
  • (1)????,??rInt????????intTwo????????,rInt??????int
    One?,??rInt?intOne????????
  • (2)rIntintTwo ???intOneintTwo
  • ?????????????,??????,???????????????,??,?????????
    ???????????????????

17
??? ??
  • 9.1 ?????
  • 9.2 ?????
  • 9.3 ??????
  • 9.4 ?????????
  • 9.5 ?????

18
9.3 ??????
  • ????????T,????,????T????????,??????T???????????
  • ??????T??????????,???????T?????????????,????????
    ??????
  • ??????????
  • double rr1

19
9.3 ??????(?1)
  • ??????
  • (1)??????????
  • (2)???????????
  • (3)??,????????????????
  • ??????????
  • double temp
  • tempdouble(1)
  • double rrtemp

20
9.3 ??????(?2)
  • ??
  • (1)?????????????????,???,?????????????????
  • (2)?????????????????????
  • int a
  • int pa //??int ???p????a
  • int b8
  • pb

21
9.3 ??????(?3)
  • ??
  • (1)?void ??????????
  • (2)??????????
  • (3)????????????,?????????,?????????
  • (4)????????????

22
??? ??
  • 9.1 ?????
  • 9.2 ?????
  • 9.3 ??????
  • 9.4 ?????????
  • 9.5 ?????

23
9.4 ?????????
  • ????
  • 1. ??????
  • 2. ???????

24
1.??????
  • ?????????????????,????????????,?????????????????
    ????

25
  • ??????
  • (1)?8.6??,???swap(int,int)????????????????????,???
    ????????????
  • (2)?????????swap(int ,int )?????,?????????,?????
    ?????????????????,?swap()???????????(dereference)(
    px),???????????????,????????????,?swap()????????
    ?????????swap(x,y)????????????????????

26
  • ??????swap()?????????
  • //ch9_4.cpp
  • includeltiostream.hgt
  • void swap(int rx,int ry)
  • void main()
  • int x5 int y6
  • coutltltbefore swap,xltltxltlt,yltltyltltendl
  • swap(x,y)
  • coutltltafter swap,xltltxltlt,yltltyltltendl
  • void swap(int rx,int ry) //??
  • int temp
  • temprx rxry rytemp

27
  • ? (?)
  • ??
  • before swap, x5 ,y6
  • after swap, x6 ,y5
  • ??
  • ?????,??swap()??????x?y,????????????????????,?????
    ???????????????????,????????????????,C??????????
    ??????

28
1.??????(?1)
  • ??
  • ?????????,????????????,???????????????????????????
    ??????,????????????

29
2.???????
  • ?????????????????????????,????????????????
  • ?????????????????????????a?b????????,????????????
    ??,?????????
  • int a 10 int b 20
  • swap(a,b)

30
2.???????(?1)
  • ??????????????????????,??????????????????????????
    ?

31
??? ??
  • 9.1 ?????
  • 9.2 ?????
  • 9.3 ??????
  • 9.4 ?????????
  • 9.5 ?????

32
9.5 ?????
  • ??????????
  • ??????????????????????????????????????,?????????
    ????????????????????????,?????????????????????????
    ?????,?????????????,??????????????
  • ?????????????????

33
  • ???????????????,?????,?????????
  • //ch9_5.cpp
  • includeltiostream.hgt
  • int Factor(int, int ,int)
  • void main()
  • int number,squared,cubed,error
  • coutltltEnter a number(020)
  • cingtgtnumber
  • errorFactor(number,squared,cubed)
  • if(error) coutltltError encountered! \n
  • else
  • coutltltNumberltltnumberltltendl
  • coutltltSquaredltltsquaredltltendl
  • coutltltCubedltltcubedltltendl

34
  • ? (?)
  • int Factor(int n, int rSquared,
  • int rCubed)
  • if(ngt20 nlt0) return 1
  • rSquared nn
  • rCubed nnn
  • return 0
  • ??
  • Enter a number(020)3
  • Number 3
  • Squared 9
  • Cubed 27

35
9.5 ?????(?1)
  • ??
  • Factor()??????????????????020????,??????????(????
    ?????0)??????????squared? cubed????????????????,??
    ??????????
Write a Comment
User Comments (0)
About PowerShow.com