Advertisement
Spocoman

Bus

Oct 9th, 2023
939
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int passengers, stations, outputPassengers, inputPassengers;
  7.     cin >> passengers, stations;
  8.  
  9.     for (int i = 1; i <= stations; i++) {
  10.         cin >> outputPassengers >> inputPassengers;
  11.  
  12.         passengers += inputPassengers - outputPassengers;
  13.  
  14.         if (i % 2 == 1) {
  15.             passengers += 2;
  16.         }
  17.         else {
  18.             passengers -= 2;
  19.         }
  20.     }
  21.  
  22.     cout << "The final number of passengers is : " << passengers << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement