I was trying to solve the problem on Java even though the code is working on my IDE it is giving an error on SPOJ can someone help me with what am I going wrong?
This is my code :
import java.util.Scanner;
import java.lang.*;
/**
*
-
@author RAHUL KUMAR JHA
*/
public class Main {
static int rev(int p){ //Reverse Driver
int temp,rev=0;
while(p!=0){
temp=p%10;
rev=(rev*10)+temp;
p=p/10;
}
return rev;
}
static int pal(int q){//Pallindrome Driver
boolean flag=false;
while(flag!=true){
int k=rev(q);
if(q==k){
flag=true;
}
else{
++q;
}
}
return q;
}
public static void main(String[] args)throws Exception {
try{
Scanner read=new Scanner(System.in);
int var=read.nextInt();
for (int i=0;i<var;i++){
int a=read.nextInt();
System.out.println(pal(++a));
}}
catch (Exception e){
return;
}
}
}