Friday, September 22, 2023

Flight

 #include <iostream>

using namespace std;

int

main ()

{

  int N = 5, i, j;

  int a[5][5] = 

  { 0, 1, 1, 0, 1,

    0, 0, 0, 1, 0,

    0, 1, 1, 1, 1,

    1, 1, 0, 1, 0,

    0, 0, 1, 1, 1

  };

  cout << "Start? ";

  cin >> i;

  cout << "Finish? ";

  cin >> j;

  if (a[i][j] == 0)

    cout << "No direct flight" << endl;

  else

    cout << "There is a direct flight" << endl;

  int p = 0;

  for (int k = 0; k < N; k++)

    if (a[i][j] == 0)

      if (a[i][k] == 1 && a[k][j] == 1)

{

  cout << "There is a flight from " << i << " to " << j <<

    " with stop in " << k << endl;

  p = 1;

}

  if (p == 0)

    cout << "There is not flight with one stop" << endl;

  return 0;

}


No comments:

Post a Comment

NaCl.xyz Generator with Interactive 3D Visualization

NaCl.xyz Generator with Interactive 3D Visualization NaCl.xyz Generator with Interactive 3D Visualization ...