generate functionTue, 24 Jan 2023

Two positive integer values a,b (a≧b) with 100 digits or less on standard input. A program that calculates the difference (a-b) and prints it to standard output.

import java.lang.Math; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main (String [] args) { Scanner scanner = new Scanner(; String a = scanner.nextLine(); String b = scanner.nextLine(); BigInteger bigA = new BigInteger(a); BigInteger bigB = new BigInteger(b); System.out.println(bigA.subtract(bigB)); } }

Questions about programming?Chat with your personal AI assistant