Академический Документы
Профессиональный Документы
Культура Документы
CS1010E Lecture 12
Problem Solving Methodology
Henry Chia
hchia@comp.nus.edu.sg
Problem Solving
Lecture Outline
General problem solving
Language
Modeling
Maze Example
Abstract Mechanism
Assignment
Expression evaluation: arithmetic, relational,
boolean
Type conversions
Function call/activation/termination
Control flow (flow chart)
if..else, switch..case
while, do..while, for
Pointers, arrays/strings and structures
Maze Example
Problem Formulation
Get starting and ending positions;
while (destination is not reached)
{
if (you can turn left)
turn left;
else
if (you can go forward)
stay put;
else
if (you can turn right)
turn right;
else
turn back;
Maze Example