Answer to Question #27691 in C for gene
a X Y Z
for Create a city and Add an edge between two cities. The symbols W,X,Y,Z all stand for "arbitrary" integers. Each "city" will be "named" with a distinct integer, specifically the one included in the "c" command. In the "a" command (add an edge) the edge should be From X To Y, with Cost Z. To make the program a bit easier, all the "Create" commands will precede any "Add" commands in the input file, AND, that the create command will be listed in increasing numerical order of the city name. You should assume an upper limit of 150 cities, "named" 1-150 "names" of the nodes will be consecutive integers starting at 1.
So, here is what the input file might look like for a four-city problem.
a 1 2 1900
a 1 3 1950
a 1 4 1400
a 2 3 150
a 2 4 3100
a 3 4 3150
As input to your Minor 7 program, you should read (from stdin) 4 integers, in the order specified below:
number of cities
minimum distance value between two cities
maximum distance value between two cities
an integer to provide input to the function srand, which will "seed" (start) the random number generator "random"
The program should generate a 'c' command for each city, in increasing numerical order, followed by as many 'a' commands as are necessary to list the distances between each distinct pair of cities. Use random() to generate random integers values for the distance between each city.
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!