-
Notifications
You must be signed in to change notification settings - Fork 0
/
flight.cpp
37 lines (37 loc) · 892 Bytes
/
flight.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
using namespace std;
int main()
{
int n;
string city[20];
int adj_matrix[50][50];
cout << "Enter the no. of cities : ";
cin >> n;
for (int i = 0; i < n; i++)
{
cout << "Enter the name of city " << i + 1 << ": ";
cin >> city[i];
}
for (int i = 0; i < n; i++)
{
for (int j = i + 1; j < n; j++)
{
cout << "Enter the time required to travel from city " << city[i] << " to the " << city[j] << "" << endl;
cin >> adj_matrix[i][j];
adj_matrix[j][i] = adj_matrix[i][j];
}
}
for (int i = 0; i < n; i++)
{
cout << "\t" << city[i] << "\t";
}
for (int i = 0; i < n; i++)
{
cout << "\n"
<< city[i];
for (int j = 0; j < n; j++)
{
cout << "\t" << adj_matrix[i][j] << "\t";
}
}
}