LFPS - Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Swapping digits in Four digit variable

2 posters

Go down

Swapping digits in Four digit variable  Empty Swapping digits in Four digit variable

Post by shirish.vogga 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
shirish.vogga
shirish.vogga
New LSF Member
New LSF Member

Posts : 3

Back to top Go down

Swapping digits in Four digit variable  Empty Re: Swapping digits in Four digit variable

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

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

Posts : 46

http://futballfps.0wn0.com

Back to top Go down

Back to top

- Similar topics

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