Skip to content

Instantly share code, notes, and snippets.

@Jack-Saleem
Created July 17, 2016 13:56
Show Gist options
  • Save Jack-Saleem/6694e6aff034402da0125b73c6fb05b5 to your computer and use it in GitHub Desktop.
Save Jack-Saleem/6694e6aff034402da0125b73c6fb05b5 to your computer and use it in GitHub Desktop.
codeforces 616A ComparingTwoLongIntegers program in java
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