Swapping digits in Four digit variable

View previous topic View next topic Go down

Swapping digits in Four digit variable

Post by shirish.vogga on Sun Aug 15, 2010 8:45 pm

Code:
class Gattu
{
static int swap(int a)
{
        int e=a/1000;          //a=8719//
        int g=a%1000;        //g=719//
        int o=g/100;            //o=7//
        int j=g%100;          //j=19//
        int z=j*100;            //z=1900//
        int y=e*10;            //o=70//
        int w=o;                //w=8//
        int v=z+y+w;
        return(v);
}
        public static void main(String[] args)
{
        int x=Integer.parseInt(args[0]);
        int p=Gattu.swap(x);
        System.out.println("the answer is "+p);
}
}     


Code:
E:\Program Files\Java\jdk1.6.0\bin>java Gattu 8719
the answer is 1987
avatar
shirish.vogga
New LSF Member
New LSF Member

Posts : 3

Back to top Go down

Re: Swapping digits in Four digit variable

Post by kiran on Tue Aug 17, 2010 5:03 pm

wah!!!!!!!!!!!!!!
Shrish!!!!
avatar
kiran
LSF Regular
LSF Regular

Posts : 46

http://futballfps.0wn0.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum