Top Banner
หหหหหหหหหหหห หหหหหหหหหหหหหหหหหห บบบบบ 2 บบบบบบบบบบบบบบ
36

511001 หลักการเขียนโปรแกรม#2 Flowchart

Jul 29, 2015

Download

Documents

Welcome message from author
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

2

" " syntax Structure Programming input, process output syntax

Structure Programming

3 (Sequence) (Decision) (Loop) Decision If Case Loop While Until 5 3

Structure Programming 2.1

(Sequence) 3 (Flowchart)

Structure Programming 2.2

(Decision) 2

Structure Programming 2.3 (Repeation or Loop)

2 (Flowchart) (do while)

Algorithm (Algorithm)

Pseudo Code (Pseudo Code)

3 Input Process Output

.. 1 : 1. 1 2. 3. 4. 5. 3

6.

: 1. 2. 3.

.. 2 : 1. set variable 2. loop 1. read number into variable 2. add number to total 3. increase counter 3. end loop 4. set average = total / counter5. print average

1: byte x; inti = 0; int total = 0; while (i < 5) { x = System.in.read(); total = total + x; i++; } double avg = total/i; System.out.println(avg);

2:

3: 4:5:

: 1. 2. 3.

.. 3 : 30 1. 30 2. 7.5 3. 30 1. 2. 3. 4. 4. 30 5. 30

.. 4 : 3 1. set sum 2. input value1 3. input value2 4. input value3 5. calculate sum = value1 + value2 + value3 6. write sum

.. 5 : 1. turn on calculator 2. clear calculator 3. repeat the following instructions 1. key in baht amount 2. key in decimal point(.) 3. key in satang amount 4. until all prices have been entered 5. write down total price 6. turn off calculator

.. 6 : 1. 2. 3. 1. 1. 2. 1.

.. 7 : #1

.. 7 : #11. 2. 3. 4. 1. 5. 1. 6. 1.

.. 8 : #21. 2. 3. 4. 5. 1. 6. 1. 7.

.. 9 : bubble sort1. i = 1 count - 1 1. j = i + 1 count 1. i j 1. i j 2. i 1 i 1

i=1 8, 5 ,4 , 6, 8 8, 5 ,4 , 6, 8

8, 5 ,4 , 6, 8 5, 8 ,4 , 6, 8

i=2 5, 8 ,4 , 6, 8 5, 8 ,4 , 6, 8 5, 8 ,4 , 6, 8 5, 4 ,8 , 6, 8 i=1

(Flowchart)

(System

Flowchart) :

(Programming Flowchart)

1.2. 3.

4.5.

(Problem Define) (Step Flowing) (Easy to Debug) (Easy to Read) (Flexible Language)

1. 2. 3. (Flow Line) 4.

( ) 5. 6. 7.

8.

()

/

() / / /

/

Flowchart 1

- 0 4

Flowchart

Result 1 12 123 1234 12345

Flowchart Flowchart 1-9