1. Trang chủ
  2. » Luận Văn - Báo Cáo

chapter 1 algorithm

12 0 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

TALENTS FOR DEVELOPMENT - Petrovietnam UniversityChapter 1: AlgorithmLecturer: Trần Ngọc Hiệp, MSc.Email: hieptn@pvu.edu.vnMobile: 0901 25 2468... Foundations of Engineering II- PVUTALEN

Trang 1

TALENTS FOR DEVELOPMENT - Petrovietnam University

Chapter 1: Algorithm

Lecturer: Trần Ngọc Hiệp, MSc.Email: hieptn@pvu.edu.vnMobile: 0901 25 2468

Trang 2

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

Trang 3

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

Trang 4

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

1.3 Algorithm Designing tools

Algorithm Designing tools:

1 pseudo codes2 flowcharts

1.3 Algorithm Designing tools

1 Pseudo codes

• Pseudo code is an artificial and informal language that helps the programmers to develop algorithm in the text format.

7

Trang 5

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

1.3 Algorithm Designing tools

2 flowcharts

• Flowchart is the diagrammatic way of representing, the steps to be followed for solving the given problem.

1.3 Algorithm Designing tools

9

Trang 6

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

1.3 Algorithm Designing toolsExample 1

• Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing The final grade is calculated as the average of four marks.

- Input a set of 4 marks

- Calculate their average by summing and dividing by 4- if average is below 50

Print “FAIL”

Print “PASS”

11

Trang 7

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

1.3 Algorithm Designing toolsFlowchart: Example 1

Step 1: Input Q1,Q2,Q3,Q4

Step 2: GRADE  (Q1+Q2+Q3+Q4)/4 Step 3: if (GRADE <50) then

Print “FAIL”else

Print “PASS”end if

1.3 Algorithm Designing toolsPseudo codes: Example 2

- Input the length in feet (Lft)

- Calculate the length in cm (Lcm) by multiplying LFT with 30

- Print length in cm (LCM)

13

Trang 8

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

1.3 Algorithm Designing toolsFlowchart: Example 2

Step 1: Input Lft

Step 2: Lcm  Lft x 30 Step 3: Print Lcm

Lcm Lft x 30

15

Trang 9

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

1.3 Algorithm Designing toolsFlowchart: Example 3

Trang 10

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

7.5 Summary

1• What is an algorithm?2• Characteristic of algorithm3• How to writing algorithm

1.4 QUIZ

19

Trang 11

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

Home Work

across a river He has a rowboat, and it can only carry him and one other thing If the fox and the chicken are left together, the fox will eat the chicken If the chicken and the corn is left together, the chicken will eat the corn How does the man do it? Solve the problem and make a flow chart with solution.

21

Trang 12

Trần Ngọc Hiệp, MSc Foundations of Engineering II- PVUTALENTS FOR DEVELOPMENT - Petrovietnam University

23

Ngày đăng: 17/06/2024, 15:00