Advertisement
Guest User

Untitled

a guest
Jun 12th, 2019
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class bus {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int countPassengersBeginning = Integer.parseInt(scanner.nextLine());
  8.         int countStops = Integer.parseInt(scanner.nextLine());
  9.         int newPassengers = 0;
  10.         int totalPassengers = 0;
  11.  
  12.         for (int i = 1; i <= countStops; i++) {
  13.  
  14.             int slizashti = Integer.parseInt(scanner.nextLine());
  15.             newPassengers = countPassengersBeginning - slizashti;
  16.             if (i % 2 == 1){
  17.                 newPassengers +=2;
  18.             } else if (i % 2 == 0) {
  19.                 newPassengers -= 2;
  20.             }
  21.  
  22.             int kachvashti = Integer.parseInt(scanner.nextLine());
  23.             newPassengers = countPassengersBeginning + kachvashti;
  24.             if (i % 2 == 1){
  25.                 newPassengers +=2;
  26.             } else if (i % 2 == 0) {
  27.                 newPassengers -= 2;
  28.             }
  29.  
  30.  
  31.         }
  32.         System.out.println(newPassengers);
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement