Created
August 12, 2013 08:43
-
-
Save yask123/6209202 to your computer and use it in GitHub Desktop.
This file contains 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
public class Palin | |
{ | |
public static void main(String args[]) | |
{ | |
Palin ob = new Palin(); | |
int max=0;int tmp=0; | |
for(int i=100;i<999;i++) | |
{ | |
for(int j=100;j<999;j++) | |
{ | |
tmp=i*j; | |
if(max<tmp) | |
{ | |
if(ob.checkPalin(max)) | |
{ | |
max=i*j; | |
} | |
} | |
} | |
} | |
System.out.println("The result is "+max); | |
//This is for testing purpose only | |
int n=1234; | |
int r=0; | |
int rev=0; | |
while(n>0) | |
{ | |
r=n%10; | |
rev=rev*10+r; | |
n=n/10; | |
} | |
System.out.println(" ~ Test"+rev); | |
} | |
boolean checkPalin(int n) | |
{ | |
int r=0; | |
int rev=0; | |
int temp=n; | |
while(temp>0) | |
{ | |
r=temp%10; | |
rev=rev*10+r; | |
temp=temp/10; | |
} | |
if(n==rev) | |
{ | |
System.out.println("I am thinking "+n+" is palin , is it?"); | |
return(true); | |
} | |
else | |
{ | |
return(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment