Guest User

Untitled

a guest
Nov 23rd, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. int searchFlights(int flightIdx[],
  2.     Flight flights[], int nFlights,
  3.     const string & orig, const string & dest)
  4. {
  5.  
  6.         int j = 0;
  7.         for (int i=0; i<nFlights; i++)
  8.         {
  9.                 if  (flights[i].get_orig() == orig && flights[i].get_dest() == $
  10.                 {
  11.                         flightIdx[j] = i;
  12.                         j++;
  13.                 }
  14.         }
  15.  
  16.         return j;
  17. }
  18.  
  19. ////////////////////////////////////////
  20. // 'searchFlight' searches for flight given 'airline' and 'flightNum'
  21. //     in array 'flights' with 'nFlights' flights
  22. // return index into 'flights' of matching flight
  23. // or -1 if not found
  24.  
  25. int searchFlight(Flight flights[], int nFlights,
  26.     const string & airline, int flightNum)
  27. {
  28.     for (int i=0; i<nFlights; i++)
  29.         {
  30.                 if (flights[i].get_airline() == airline && flights[i].get_fligh$
  31.                         return i;
  32.  
  33.                 else
  34.                         return -1;
  35.  
  36.         }
  37. }
Add Comment
Please, Sign In to add comment