6.8 Linked Lists and Structures6 Assignments6.6 Returning multiple values6.7 Find a route

6.7 Find a route

This program will use scanf (fscanf) to input data and a number of arrays to process the data.

The program will first input a data set that the first part is composed of records that have four data elements. The first two are zip codes, the third is the distance, in miles, between the two zip codes. The last field is a comment. These records represent a rode between two cities. A route, in this case can be traveled either direction. All three values will be integers.

This section of the data is terminated by a record with all three values set to zero.

The next section in the data file is a set of records that have two zip codes. For each pair of zip codes find a route between the zip codes. There is a third field that has a comment.

Be able to get your data both from the standard input or a specified file name.

The data set is "guaranteed" to have less than 500 roads and less than 250 zip codes. But, use #define pre-processor statements to define these limits (if you need limits).

For extra credit, find multiple routes and select the shortest (and longest?) route.

At the start of your program print out:

Then for each route requested print out:

At the end of your program print the following summary:

Given the following example input.

85716 95949  820 Tucson-GrassValley
99801 95949 1400 GrassValley-Alaska
00000 00000   00
85716 99801      Tucson-Alaska
85716 34562      Tucson-?
00000 00000
This output should be in (about) the following format:

Your name
CIS265  Louis Taber
Lab: 6.6: Find a route

3 roads read in.

1. Route from 85716 to 99801
   85716 to 95949   820 miles
   95949 to 99801   400 miles
** 85716 to 99801  1240 miles

2. Route from 85716 to 34562
** No route available: zip 34562 not found.

Summary:
   1 route(s) found.  Total 1240 miles.  Total 2 roads.
   1 route not found 
Test your program with the following sample data set. It is available by anonymous FTP at
ftp://lt.tucson.az.us/pub/c/route.dat.

Study areas:

Hints:

Turn in a copy of your program and its output when used with the above test data marked with:

Please turn your lab in to Pima Community College employee in room A-115 ofthe Santa Rita Building. Ask them to place it in the lab folder in Louis Taber's mailbox.
Instructor: ltaber@pima.edu ** My new Home at GeoApps in Tucson ** The Pima College Site

6.8 Linked Lists and Structures6 Assignments6.6 Returning multiple values6.7 Find a route