This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Flowcharts
• So let’s say we want to express the following algorithm to print out the sum of the biggest and smallest of three numbers
START
START
Read in A, B and C
START
A>B?
Read in A, B and C
START
A>B?
Read in A, B and C
YesA>C?
START
A>B?No
Read in A, B and C
YesA>C? B>C?
START
A>B?No
Read in A, B and C
YesA>C? B>C?
Biggest = C
NoNo
START
A>B?No
Read in A, B and C
YesA>C? B>C?
Biggest = A Biggest = C
Yes
NoNo
START
A>B?No
Read in A, B and C
YesA>C? B>C?
Biggest = A Biggest = C Biggest = B
Yes Yes
NoNo
START
A>B?
No
Read in A, B and C
YesA>C? B>C?
Biggest = A Biggest = C Biggest = B
Yes Yes
No
No
A>B?
A>B?Yes
B<C?
A>B?Yes
B<C? A<C?No
A>B?
No
YesB<C? A<C?
No
No
A>B?
No
YesB<C? A<C?
Smallest = C
No
No
A>B?
No
YesB<C? A<C?
Smallest = A Smallest = C
Yes
No
No
A>B?
No
YesB<C? A<C?
Smallest = A Smallest = C Smallest = B
Yes Yes
No
No
A>B?
No
YesB<C? A<C?
Smallest = A Smallest = C Smallest = B
Yes Yes
No
No
A>B?
No
YesB<C? A<C?
Smallest = A Smallest = C Smallest = B
Yes Yes
No
No
Print Smallest + Biggest
A>B?
No
YesB<C? A<C?
Smallest = A Smallest = C Smallest = B
Yes Yes
No
No
Print Smallest + Biggest
END
Flowcharts
• So let’s say we want to express the following algorithm to print out the biggest of four numbers