Code:
- UW PICO(tm) 2.3 File: part1.c-------------------Modified
#include <stdio.h>
#include <string.h>
int menu_ops(void);
void display(int[][]);
int main(void)
{
int p1;
int p2;
int distance[10][10] =
{
{ 0,23,12,89,456,123,46,732,345,123},
{ 23,0,46,234,123,46,89,234,567,90},
{ 12,46,0,767,456,46,234,123,732,35},
{ 89,234,767,0,732,32,48,67,98,100},
{ 456,123,456,732,0,234,46,89,89,732},
{ 123,46,46,32,234,0,123,46,123,234},
{ 46,89,234,48,46,123,0,46,89,19},
{ 732,234,123,67,89,46,46,0,123,732},
{ 345,567,732,98,89,123,89,123,0,78},
{ 123,90,35,100,732,234,19,78,732,0}
};
int option,rtn;
option = menu_ops();
while(option != 'Q' && option != 'q')
{
switch(option)
{
case 'a': case 'A': /*display distance between 2 points */
break;
case 'b': case 'B': /*display distance and cost */
break;
case 'c': case 'C': /*display milage chart */
display(distance);
break;
default: printf("Invalid choive try again");
}
option = menu_ops();
}
return 0;
}
int menu_ops(void)
{
char opt;
char rtn;
printf("\n A. Display distance between 2 points\n");
printf("B. Display distance between 2 points and the cost\n");
printf("C. Display the milage chart\n");
printf("please enter your option (Q quits the sytem): ");
scanf("%c%c", &opt,&rtn);
return opt;
}
void display(int chart[10][10])
{
int row, col;
for (row=0; row<10;row++)
{
for (col=0; col<10;col++)
printf("%4d", chart[row][col]);
printf("\n");
}
}