Advertisement
dsdeep

URI 1047 Java

Sep 8th, 2020 (edited)
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. import java.util.Scanner;
  2. class Main {
  3.   public static void main(String[] args) {
  4.     Scanner scanner=new Scanner(System.in);
  5.     int h1=scanner.nextInt();
  6.    
  7.     int m1=scanner.nextInt();
  8.     int h2=scanner.nextInt();
  9.     int m2=scanner.nextInt();
  10.     int hour=0,min=0;
  11.     if(h2>h1){
  12.          hour=h2-h1;
  13.     }
  14.     else if(h2==h1){
  15.       if(m2>m1){
  16.         hour=0;
  17.       }
  18.       else{
  19.       hour=24;
  20.       }
  21.     }
  22.     else{
  23.       hour=(h2-h1)+24;
  24.     }
  25.     if(m2==m1){
  26.       min=0;
  27.     }
  28.     else if(m2>m1){
  29.       min=m2-m1;
  30.     }
  31.     else{
  32.       min=60-(m1-m2);
  33.       hour=hour-1;
  34.     }
  35.  
  36. System.out.println("O JOGO DUROU "+hour+" HORA(S) E "+min+" MINUTO(S)\n");
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement