Purpose: Process a stream of data. Use loops & conditional statements Descriptio
ID: 3637785 • Letter: P
Question
Purpose: Process a stream of data.
Use loops & conditional statements
Description:
Create a C program that reads in a stream of integer pairs,
each representing an (x,y) pair in the cartesian coordinate
system. For each successive pair of integers, display the
distance and direction traveled from one pair to the next.
You can assume that in each successive pair only one value
changes, so that travel is always right, left, up, or down.
{This would be like the locations displayed in the tracker.c
example from the "Conditional Statements" section in
Polzin's online notes (the x, y values.) }
Also, keep a running total of the distance between each pair
of points and determine the distance between the
initial/starting point and the final/finish point.
Ex:
--
Data:
0 0
0 3
4 3
2 3
2 2
Output:
0 0 <- Start
0 3 <- Distance: 3 Direction: Up
4 3 <- Distance: 4 Direction: Right
2 3 <- Distance: 2 Direction: Left
2 2 <- Distance: 1 Direction: Down
2 2 <- Finish
Total distance between successive points: 10
Distance between start and finish: 2.828427