Represent the real numbers

Assignment Help C/C++ Programming
Reference no: EM13937065

Assume you are given a set of N < 10 cities with pairwise distances between them represented as real numbers. A traveler starts from city #1 and wants to visit all other cities just once and return back to the origin. Assume there is a direct airline between any two of these N cities. Your task is to design a C++ program that will find an optimal route for the traveler. That is, the program should return a route of minimum total length. Assuming that the traveler always starts from city 1 the output of the program for N = 4 should be of the form
1 -> 2 -> 4 -> 3 : 226.6

where the last number is the minimum total distance.

Create a file dist.dat for storing the pairwise distances represented as an NxN table of numbers. The number at the intersection of the i-th column and j-th row is the distance from city i to city j. So the table is symmetric; that is, the number at the intersection of row i and column j is the same as the one at the intersection of column i and row j. Note that the number N of cities is not presented explicitly in the file, your program has to figure it out. Your program should read the data from the file by using the input redirection.

Example of such file for N = 4:

56.78 11.80 79.34 78.23
11.80 16.26 65.23 45.19
79.34 65.23 63.29 90.27
78.23 45.19 90.27 87.35

Create your own file for at least 7 cities.
Your program should work for any N in the range [3..10]

Reference no: EM13937065

Questions Cloud

Exploit be demonstrated safely in-class : Task: You are required to create and deliver a presentation providing an analysis of an existing software exploit (therefore you are not required to craft a new, unknown exploit yourself).
Ethical philosophy of an organisation : The ethical philosophy of an organisation is usually embedded into the culture of the organisation by its leaders. Describe what ‘leadership by example' is and how it helps create an ethical culture.
What is the hormone that is tested for in pregnancy : Pregnancy can be detected several days post-implantation, based on a hormone level test. What is the hormone that is tested for in pregnancy, and what is its role? How is the test administered, and who may perform it?
Future career in health care : Consider your future career in health care. What opportunities will you have to promote health enhancing behaviors and discourage health compromising behaviors?
Represent the real numbers : Assume you are given a set of N
Socioeconomic status affects health : How race, gender and socioeconomic status affects health
Explain the importance of sexual reproduction : As you can see in these three life cycles, those of higher organisms tend to emphasize the diploid stages more than the haploid stages. Explain why there has been a trend toward diploidy among higher organisms; what are the advantages of being dip..
What are the mix of product you wish to concentrate on : 1. What are the mix of product you wish to concentrate on? -how is your product similar/different to that of competitors
Evaluate its employees four times a year at the end of year : The data will be validated and saved to an output file,"datainput" . this program will use five arrays to grater manupliate and store the data.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Afunction that raises an integer to a positive integer

Write a function that raises an integer to a positive integer power. Call the function x_to_the_n, taking two integer arguments x and n.

  Task 1 write compile and run the following two programs

task 1 write compile and run the following two programs using cc programming method. select the appropriate defined

  Write a program to analyze students course marks

Write a program to analyze students course marks. The program should read in students course marks from "m2-grading.txt". The data file has a headline including students ID#, course-1marks, course-2 marks and course-3 markes.

  Complete the design and implementation

Complete the design and implementation of the class customerType defined in the Programming Example Video Store. b. Design and implement the class customerListType to create and maintain a list of customers for the video store.

  Design an application for the homestead furniture

Design an application for the Homestead Furniture Store that gets sales transaction data, including an account number, customer name, and purchase price. Output the account number and name, then output the customer's payment for each month for the ne..

  Write unique, simple function in c++

Write unique, simple function in C++. Be sure you provide code that calls the function also. Visual Studio

  Determines the largest value

Write a program Largest that reads three integers from the user and determines the largest value - Write a program InOrder that reads three integers from the user and prints the three integers in sorted order.

  Write the definition of the member function two of yclass

Write the definition of the member function two of yClass so that the private member variable a is initialized to the value of the first parameter of two, and the private member variable b is initialized to the value of the second parameter of two..

  Extension of a filename

Modify your earlier program that found the extension of a filename. This time your program will identify a file name that is no longer that 12 characters and has one of five extensions that you specify (eg: .doc. .py, .html, .txt, .ps).

  Write a c program that will read the required values

Write a C program that will read the required values from the input file, compute the hole to depth ration, the ideal number of sticks, the ideal powder charge, the actual powder charge, and the actual number of sticks.

  Prompts the user to input the shipping cost per liter

Write a program that does the Prompts the user to input the dimensions (in feet) of the container (radius the container (radius of the base and the height)

  Program for how to indicate the family member entry

Program for how to indicate the family member entry is complete

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd