A Distance calculating program

How to make a program like if user enter two cities got it's total distance as output. I am quite newb in C++ so help me out.


Here is the table for question

[img]http://jarralpics.com/image-F5CD_49BFB6C7.jpg[/img]


if user enter city 1 and city 2 out put will be 95
You can create a 2D array and store there the value of the distances and then access them by subscripting

eg:
1
2
3
4
5
6
int array[4][4] = {
    {   0,  95, 173, 103 },
    {  95,   0, 101, 192 },
    //...
};
Distance_from_city2_and_city3 = array[2][3];
Last edited on
Topic archived. No new replies allowed.