Principle of computer problem solving - PowerPoint PPT Presentation

About This Presentation
Title:

Principle of computer problem solving

Description:

– PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 33
Provided by: KBanjo
Category:

less

Transcript and Presenter's Notes

Title: Principle of computer problem solving


1
??????????? Algorithms
2
??????????????????????????????
  • ???????????? (Natural languge)
  • ??????????????????????????????????????????????
    ??????? ????????? ????????????????????
  • ????????? (Pseudocode)
  • ??????????????????????????????????????????????????
    ?????? ????????????????????????????????
    ?????????????????????????????????????????????
  • ?????? (Flowchart)
  • ??????????????????????????????

3
?????? (Flowchart)
????????
??????????
?????????
  • ???????? American National Standards Institute
    (ANSI)
  • ??????????????????????
  • ???????????????????????
  • ?????????????????????????????????
  • ?????????????????????????????????????????????????
    ???????????

??????????????
????????
?????????
??????????
??????
?????????
??????????????
??
4
????????? (Pseudocode)
  • ???????????????
  • ????????????? ??????????????????????
  • ?????????????????????????????????????????????????
    ???????????????????????? ?????????????????????????
    ?????????????????
  • ?????????????????????????????????????????????????
    ??????????? ???????????????????????????????
  • ????????????????????????????????
  • ????????????????????????????????

5
???????????
  • ?????????????????????? 2 ????
  • ????????????????? (Sequential operations)
  • ?????????????????? (Control Operation
  • 2.1 ???????????????????? (Conditional operations)
  • 2.2 ??????????????? (Iterative operations)

6
Sequential Operation
Start
Find phone number
  • ??????????????????????
  • 1. ????????????
  • 2. ????????? ??????????
  • 3. ??????????????
  • 4. ?????????????
  • 5. ?????
  • 6 ???????
  • 7. ?????????????

Enter phone number and Press the call button
Algorithm 1. Find phone number 2. Enter phone
number and press call button 3. Listen to phone
signal 4. Say hello 5. Make conversation 6. Say
Good bye 7. Hang up a call
Listen to signal
Say hello
Make conversation
Say good bye
Hang up a call
Stop
7
???????? (Computation)
  • Set variable to arithmetic expression
  • ????????????????????? (arithmetic expression)
  • ????????????????????????????? (variable)
  • Set a to 100
  • Set b to 200
  • Set Result to ab

300
100
200
Result
a
b
8
???????????????
  • ????????????????????????? 27.75 ???
  • ????????????????????? 15 ????
  • ?????????? ????????????????? x ???????????
  • ???? ??????????

Start
priceperitem 27.75 quantity 15
Set priceperitem to 27.75 Set quantity to 15 Set
price to priceperitem x quantity Print price
price priceperitem x quantity
Print price
Stop
15
27.75
price
quantity
priceperitem
9
???????????????
Set vat to 0.07 Set priceperitem to 27.75 Set
quantity to 15 Set price to priceperitem x
quantity Set tax to price x vat Set
priceincludetax to price tax Print
priceincludetax
Start
vat 0.07 priceperitem 27.75 quantity 15
price priceperitem x quantity tax price x
vat priceincludetax price tax
15
27.75
0.07
quantity
priceperitem
vat
Print priceincludetax
Stop
price
tax
priceincludetax
10
?????????????????????????????????
  • Input
  • Get variable1, variable2,
  • Get the radius of the circle
  • Get radius
  • Output
  • Print variable1, variable2,
  • Print area

11
???????????????
  • ????????????????????????????????
  • ??????????????????????????
  • ??????????????? ????????????????? x ???????????
  • ???? ??????????

Start
input priceperitem, quantity
Get priceperitem Get quantity Set price to
priceperitem x quantity Print price
price priceperitem x quantity
Print price
Stop
price
quantity
priceperitem
12
???????????????
  • ????????????????? 7
  • ????????????????????
  • ??????????????
  • ?????????? ????????????????? x ???????????
  • ???? ?????????? x ?????????
  • ????????????????? ?????????? ????
  • ?????????????????????

Start
vat 0.07
input priceperitem, quantity
Set vat to 0.07 Get priceperitem Get quantity
Set price to priceperitem x quantity Set tax
to price x vat Set priceincludetax to price
tax Print priceincludetax
price priceperitem x quantity tax price x
vat priceincludetax price tax
Print priceincludetax
Stop
13
????????????? 2 ????? ??????????????? a ??? b
?????????????????
14
Control Operation
  • ?????????????????????????????????????????????
    ???????????????????? ?????????????????????? 2
    ????
  • Conditional Operation ???????????????????
    ???????? ?????????????????????????????????????
  • Iterative Operation ???????????????????????? ????
    ????????????????????????

15
Conditional statement
  • If condition then
  • set of operation

???????? condition ??????????? ????? set of
operation
????????
false
true
T1
T2
16
??????????
Start
????????????????? ????????? ???????
????????? ????????
?????????????????
???
false
true
???????
Search for the ATM card If find the ATM card
insert the ATM card press withdrawal
button Return home
?????????
????????
Stop
17
Start
Grade U
Set grade to U Get score If (score gt 50) then
Set grade to S Print grade
get score
Score gt 50
false
true
Grade S
Print Grade
Stop
18
Conditional statement
  • If condition is true then
  • first set of operations
  • Else
  • second set of operations
  1. ???????? condition
  2. ??????????? ????? first set of operations
  3. ??????????? ????? second set of operations
  4. ????????? operation ?????? conditional statement

19
if/then/else statement
????????
true
false
S1
T1
S2
T2
S3
T3
V
20
????????????? 3 ????? ?????????????????????
Start
read a,b,c
false
a gt b
false
true
b gt c
false
a gt c
true
true
big a
big c
big b
big c
print big
Stop
21
Start
Get score If (score gt 50) then Set grade to
s Else Set grade to u Print grade
get score
Score gt 50
false
true
Grade S
Grade U
Print Grade
Stop
22
Start
Get score if (score gt 80) set grade to
G Else if (score gt 50) set grade
to P else set grade to F print
grade
get score
score gt 80
false
score gt 50
false
true
true
grade G
grade P
grade F
print grade
Stop
23
Get WorkHour,MaxHour, OTRate IF WorkHour gt
MaxHour THEN OverHour MaxHour -
WorkHour ELSE OverHour 0 ENDIF OverTime
OverHour OTRate Print OverTime
Start
Receive WorkHour, MaxHour, OTRate
WorkHour gt MaxHour
false
true
OverHour MaxHour - WorkHour
OverHour 0
OverTime OverHour OTRate
Print OverTime
Stop
24
??????????
Start
?????????????????
????????????????? ????????? ?????????????????
?????????????? ????????? ????????
?????????????????? ????????
???
false
true
?????????????????
????????????
true
?????????
??????????????????
????????
Stop
25
Loop the repetition of a block of instructions
  • ??????????????????????????????????????????????????
    ????????????
  • ?????????????????????????????????
    ??????????????????????????? ??????????????????????
    ???? ???????? ???????????????????????
  • ??????????????????????? 5 ??????
  • ????????????????????? 5000000/(60x60x24) 58
    ???
  • ?????????????? ????????????? 1 ??????

26
Looping while statement
  • While (condition) do
  • operation
  • operation
  • .
  • operation

?????????????(a true/false condition)????????
loop body ?????????? ?????????????????????????????
???? ???????????????????????????????????
operation ????????????? loop
27
????????
false
true
S1
S2
??????????????????? while loop
S3
Sn
28
Start
count 1 while count lt 100 do print count
add 1 to count
count 1
count lt 100
false
true
Print count
Add 1 to count
Stop
29
Start
count 1 while count lt 100 do print count
add 2 to count
count 1
count lt 100
false
true
Print count
Add 2 to count
Stop
30
Start
count 1 while count lt 100 do add 1 to
count add count to total print count
total 0, count 1,
count lt 100
false
true
add 1 to count add count to total
Print count
Stop
31
Start
????????????????????????????? ??????????????? 1
1 2 4 3 9
4 16 5 25 6
36 100 10000
count 1
count lt 100
false
true
square count x count
print count, square
count 1 while count lt 100 do set square to
count x count print count, square add 1 to
count
add 1 to count
Stop
32
Start
Set vat to 0.07 get priceperitem while
priceperitem ltgt 0 do get quantity
set price to priceperitem x quantity set
tax to price x vat set priceincludetax to
price tax print priceincludetax get
priceperitem
vat 0.07
Input priceperitem
priceperitem ltgt 0
false
true
input quantity
price priceperitem x quantity tax price x
vat priceincludetax price tax
print priceincludetax
Input priceperitem
Stop
Write a Comment
User Comments (0)
About PowerShow.com