View Code of Problem 56


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String str2 = sc.nextLine();
        String[] a = str1.split(":");
        String[] b = str2.split(":");
        int t1 = Integer.parseInt(a[0]) * 3600 + Integer.parseInt(a[1]) * 60 + Integer.parseInt(a[2]);
        int t2 = Integer.parseInt(b[0]) * 3600 + Integer.parseInt(b[1]) * 60 + Integer.parseInt(b[2]);
        int num = Math.abs(t1 - t2);
        int h = num/3600;
        int m = num%3600/60;
        int s = num%3600%60;
        System.out.println(String.format("%d:%02d:%02d",h,m,s));
    }
}

/*
Main.c:3:1: error: unknown type name 'import'
 import java.util.Scanner;
 ^
Main.c:3:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
 import java.util.Scanner;
            ^
Main.c:5:1: error: unknown type name 'public'
 public class Main {
 ^
Main.c:5:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main'
 public class Main {
              ^
*/

Double click to view unformatted code.


Back to problem 56