Created
July 17, 2016 13:56
-
-
Save Jack-Saleem/6694e6aff034402da0125b73c6fb05b5 to your computer and use it in GitHub Desktop.
codeforces 616A ComparingTwoLongIntegers program in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
public class ComparingTwoLongIntegers | |
{ | |
public static void main(String[] args) | |
{ | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
String x=null; | |
String y=null; | |
try { | |
x = br.readLine(); | |
y = br.readLine(); | |
} catch (IOException e1) { | |
e1.printStackTrace(); | |
} | |
x = x.replaceFirst ("^0*", ""); | |
y = y.replaceFirst("^0+(?!$)", ""); | |
if(x.isEmpty()) | |
x="0"; | |
if(y.isEmpty()) | |
y="0"; | |
if(x.length()>y.length()) | |
System.out.println(">"); | |
else if(x.length()<y.length()) | |
System.out.println("<"); | |
else | |
{ | |
if(x.compareTo(y)==0) | |
System.out.println("="); | |
else { | |
for(int i=0;i<x.length();i++) { | |
if(Character.getNumericValue(x.charAt(i))==Character.getNumericValue(y.charAt(i))) | |
continue; | |
else if(Character.getNumericValue(x.charAt(i))>Character.getNumericValue(y.charAt(i))) { | |
System.out.println(">"); | |
break; | |
} | |
else { | |
System.out.println("<"); | |
break; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment