Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- char input, town [6][13] = { "Alor Setar", "Ipoh", "Kangar", "Kuala Lumpur", "Mersing", "Melaka" };
- int i, first, second, distance [6][6] =
- {
- 0, 258, 43, 475, 876, 623,
- 258, 0, 301, 217, 616, 365,
- 43, 301, 0, 518, 918, 667,
- 475, 217, 518, 0, 401, 148,
- 876, 616, 918, 401, 0, 246,
- 623, 365, 667, 148, 246, 0,
- };
- cout << "Town Reference:\n";
- for(i=0; i<6; i++)
- cout << "\t" << i << " - " << town[i] << "\n";
- cout << "First town: ";
- cin >> first;
- cout << "Second town: ";
- cin >> second;
- cout << "Distance between " << town[first] << " and " << town[second] << " is " << distance[first][second] << " km";
- cout << "\n\nRepeat (Y or N): ";
- cin >> input;
- if(input == 'y'||input == 'Y')
- main();
- }
Add Comment
Please, Sign In to add comment