1204 102 Problem Solving - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

1204 102 Problem Solving

Description:

1204 102 Problem Solving ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 30
Provided by: AJ83
Category:

less

Transcript and Presenter's Notes

Title: 1204 102 Problem Solving


1
1204 102 Problem Solving
  • ???????? ?????????????????????????????????????????
    ?????

2
???????????????????????? (String)
  • ??????????????????????????? (char)
  • ???????????? ?????????????????? ???????? ???
    ????????????? Array ??????
  • ?????? 1 (??????????????????????????????????????)
    char ???????????????????????1
  • ?????? 2 (?????????????????????????????) char
    ?????????? ???????
  • ?????????????????? ???????????????????????????????
    ????????????????????? (??????????? Double
    Quote)
  • ???????????????????????????????????? ??????
  • ?????????? ???????
  • ????????????? ?????????????1
    ??????????????????????????????????????? ??????
    \0 ???????

3
Library ?? Header File
  • ???????? ??????????????????
  • www.cppreference.com/index.html
  • en.wikipedia.org/wiki/C_standard_library
  • www.utas.edu.au/infosys/info/documentation/C/CStdL
    ib.html
  • ????????????????????????????? ??????????????
    Header File ?????????? Include
  • include ltstdio.hgt
  • ??? Library ????????? Standard Input/Output
  • include ltconio.hgt
  • ??? Library ????????? Console Input/Output
  • include ltmath.hgt
  • ??? Library ??????????????????????????????
  • ???

4
stdio.h
  • printf() ?????? ???????????????????????????
  • scanf() ?????? ?????? Input ???????????? keyboard
  • gets() ?????? ?????? String ??? keyboard
  • puts() ?????? ???? String ????????????
  • getchar() ?????? ?????? Character ??? keyboard
  • putchar() ?????? ??????? Character ????????????
  • ???

5
???????? scanf, printf, ???????????
6
??????????? String ????????????
????????? char name20 ???
name1Algor ???????????????? name ??????
???????????????? ????????? ???????????????????????
? ??? ???? ?????????????????????????? ?????????
scanf(s,name) name1 ?????????????????????
?? ??????? Algor ???????????????????????????????
???????? ????????? printf(K.s ..,name1)
7
??????????????????????????????????

??? flowchart ??????????? ?????? 2 ??? WIDTH,
LENGTH ??? ???????!! ????????????????? ???????
???????????????????? ???????????? scanf
???????? ????????????????????????
??????? ?????????????? ??????? ??????
printf ???? ????
Output
8
????! ????????????????
  • ?????????????????????????????????????
    ??????????????????????????????? 30
    ???????????????? ??????????????????????????? 3 ??
    ????????? ??? ???????????????????????????
    ????????????????????????????
  • Flowchart ?????????????????

?????????????????? (bonus)
mom bonus x 0.3 children (bonus mom) / 3
???? ??????? ??? ??? ???? ?????? (mom, children)
9
Flowchart ??? Source Code
?????? ????????????????????????? float
includeltstdio.hgt includeltconio.hgt int main()
float bonus,mom,children
printf(Input Fathers bonusgt ) scanf(f,bon
us)
mom bonus 0.3 children (bonus mom) / 3
printf(Mother gets .2f, Children get
.2f,mom,children)
?????? printf ????? ??????????????????????
?????????????? ??? printf ?????
???????????????????? mom ??? children ??????????
??????????????????????????????????? ????
????????????????????????????????
10
????! ???????????
11
conio.h
  • getch() ???????????? character ??? keyboard
    ???????????????????????????
  • clrscr() ??????????????????????????????
  • clreol() ??????????????? ? ??????????? cursor
  • ???
  • ??. ??????????? ?? Dev-C ???????????
  • system(cls)

  • ????????? Header file ????
  • ???????????
    iostream.h ??????????
  • system(pause)
    ???????????

12
???????????? cls ??? pause
13
???????????????????????????
  • ????????????????????????????????????????
    (Keyboard) ??????????? ????
  • ?????? getch() ?????? conio.h
  • ?????? gets() ?????? stdio.h
  • ?????? scanf() ?????? stdio.h

14
getch()
  • ????????????????????????? 1 ????????????????
    ???????????? Enter ???????????????????????????????
    ?
  • ????????????????????????? ASCII ????????????
  • ???? include ???????? conio.h
  • ??????????? 2 ???
  • ??????????????????????????????? ???????????
  • char ch
  • ch getch()
  • ????????????????????????????? (???????????????????
    Key ??? ??????????????) ???????????
  • getch()

15
Example 11
  • include ltstdio.hgt
  • include ltconio.hgt
  • int main ()
  • printf("Press any key to continue\n")
  • getch( )
  • char ch
  • printf("Input one character ")
  • ch getch( ) //????????????????????????????????
    ???????????
  • printf(\nYour character is c", ch)

16
gets()
  • ???????????????? (String)
  • ???? include ???????? stdio.h
  • ????????? ???????????????????????
  • char ??????????????????????????????1
  • gets(????????????????? )
  • ????????
  • char name10
  • gets(name)

17
Example 12
  • include ltstdio.hgt
  • int main()
  • char name10
  • printf("Input name ")
  • gets(name)
  • // printf("Hello s\n",name)
  • return 0

????????? comment ??????????? 8 ??????? run
???????? ??????????????????
18
scanf()
  • ???????????????????????? ?????????????????????????
  • ???? include ???????? stdio.h
  • ?????????????????????????? ??????
  • //
    ???????????
  • ??????????????
  • d ???/?????????????????????????
  • f ???/????????????????
  • c ???/????????????????? Enter (??????????????)
  • s ???/??????????? (String)
  • ld ???/??????????????????? ??????????? 4
    ????
  • lf ???/????????????????????? ???????????
    8 ????
  • argument
  • argument ??? ?????????
  • ??? ?????????? address ?????????????????????????
    ???????????

scanf(??????, argument)
19
Data type long , double
?????? ????????????????????? ??????? ????????
?????????????????????????? ??? ????????????
??????
20
ld, lf
21
Example 13
  • include ltstdio.hgt
  • include ltconio.hgt
  • int main()
  • char ch
  • char name10
  • int num
  • float score
  • printf("Input one char ") scanf("c", ch)
  • printf("Input string ") scanf("s", name)
  • printf("Input integer ") scanf("d", num)
  • printf("Input float ") scanf("f", score)
  • printf("char(c) string(s) integer(d)
    float(f)", ch,name,


  • num,score)
  • getch()
  • return 0
  • ??. s ???????????? scanf ????????????????????????
    ???????????? gets ??????????????

22
Example 14 (???????????????????????????? 13)
  1. include ltstdio.hgt
  2. int main()
  3. char ch char name10
  4. int num float score
  5. // ?????? Input
  6. printf("Input one char ") scanf("c", ch)
  7. printf("Input string ") scanf("s", name)
  8. printf("Input integer ") scanf("d", num)
  9. printf("Input float ") scanf("f", score)
  10. // ?????? Output ??????????????? Input
    ????????????
  11. printf("Display one char is c\n", ch)
  12. printf("Display string is s\n", name)
  13. printf("Display integer is d\n", num)
  14. printf("Display float is f\n", score)
  15. return 0

23
??????????????? scanf, gets
?????? ??????????????? ???? ???? ??????????
??? ?????????????? scanf(ss,name,
surname) gets(name) ???????????????????
? ?????? ??????????????? ???? ????????????????????
????????????????? ???????????????????
24
Example 14
  1. include ltstdio.hgt
  2. int main()
  3. char ch
  4. char name10
  5. int num
  6. float score
  7. printf("Input string ") scanf("s", name)
  8. printf("Input one char ") scanf("c", ch)
  9. printf("Input integer ") scanf("d", num)
  10. printf("Input float ") scanf("f", score)
  11. return 0

?????????????? 13 ????????????? ??? 9 ??????
10 ?????? ????????????????????????? ??????????????
??????????????????
25
math.h
  • ???????????
  • abs()
  • ??????????? absolute ?????????????????????
  • fabs()
  • ??????????? absolute ?????????????????????
  • exp()
  • ????? exponential
  • fmod()
  • ?????
  • log()
  • ????? natural logarithm
  • log10()
  • ????? logarithm ??????
  • pow()
  • ???????????????
  • sqrt()
  • ??????????? 2 (square root)
  • ????????
  • int ?????? abs(argu)
  • float ?????? fabs(argu)
  • float ?????? exp(argu)
  • float ?????? fmod(argu)
  • float ?????? log(argu)
  • float ?????? log(argu)
  • float ?????? pow(??????, ????????)
  • float ?????? sqrt(argu)

26
Example 15
  1. include ltiostreamgt
  2. include ltconio.hgt
  3. include ltmath.hgt
  4. int main()
  5. printf(Press any key) getch() //
    ????????? ??? keyboard
  6. system(cls) // ????????
  7. int a, b, c // ???????????????
  8. printf(Input a ) scanf(d, a) //
    ?????? a
  9. printf(Input b ) scanf(d, b) //
    ?????? b
  10. printf(a d\nb d, a, b) // ??????? a
    ??? b
  11. cabs(a) // ????????????? a ??????????????? c
  12. printf(Show absolute of a d\n, c) //
    ??????? c
  13. printf(Show absolute of d d\n, a, c) //
    ??????? c
  14. cpow(2,3) // ????? 2 ??????? 3
    ??????????????? c
  15. printf(Show 2 power 3 d\n, c) // ???????
    c
  16. cpow(a, b) // ????? a ??????? b
    ??????????????? c
  17. printf(Show d power d d\n, a, b, c) //
    ??????? c
  18. getch()

27
Example 16
  1. include ltstdio.hgt
  2. include ltmath.hgt
  3. int main()
  4. float x, y, z
  5. printf("Input x ") scanf("f", x)
  6. printf("Input y ") scanf("f", y)
  7. printf(" x f\n y f\n", x, y)
  8. zfabs(x)
  9. printf("Show absolute of f f\n", x, z)
  10. zpow(x, y)
  11. printf("Show f power f f\n", x, y, z)
  12. zsqrt(x)
  13. printf("Show square root f f\n", x, z)
  14. return 0

28
?????????
  • ?????????????????????????????????
  • ??????????????????????????????????????????????????
    ???? 10 ??? ??????????????? 5 ??? ??? 10 ???
    ??????????????????????????????????????????????????
    ??????? ????????????????????????????????????
    ???????????????????????
  • ??????????????????????????? ???????????
    ??????????????????????????????????????????
    ??????????????????? (1 ??? 400 ???????)
  • ?????????? ???? ????? ?.?. ???????????????????????
    ???????????? ????????????????????????????
  • Name Surname, Birth Yearxxxx
  • Your age is xx

29
?????????(???)
  • ?????????????????????????????????????????????????
  • P(x) x5 3x4 2x3 x 6 ????? x
    ?????????????????? ?????????????????????????
  • ??????????????????????????????????????????????????
    ???????? R ??? H ??? ???????????????????
    ????????????????????
  • ????????????????xx.xx ,
    ???????xx.xx
  • ????????????????xxx.xx
  • f(x) x5 5x 8 ???????? x 3
  • 3x2
Write a Comment
User Comments (0)
About PowerShow.com