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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <iostream>
#include <string.h>
using namespace std;
string response;
int main ()
{
int array[4][4] = {
{ 0, 100, 180, 109 },
{ 100, 0, 101, 192 },
{ 173, 101, 0, 255 },
{ 103, 191, 255, 0 },
};
char *cities[]={"city1",
"city2",
"city3",
"city4"
};
cout <<"\t city1 and city2" <<endl;
cout <<"\t city2 and city3"<<endl;
cout <<"\t city3 and city4" <<endl;
cout <<"\t city4 and city1" <<endl;
int i;
string response;
cout <<"\t Select 2 cities:" <<endl;
getline (cin,response);
if (response == "city1 and city2") {
cout << " Total Distance = " ;
cout<<array[0][1]<<endl;
}
else if (response == "city2 and city3")
{
cout << " Total Distance = " ;
cout<<array[0][2]<<endl;
}
else if (response == "city3 and city4"){
cout << " Total Distance = " ;
cout<<array[0][3]<<endl;
}
else if (response == "city4 and city1"){
cout << " Total Distance = " ;
cout<<array[0][4]<<endl;
}
else
{
cout <<"Incorrect!";
}
system ("pause");
}
| |