Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.*;
- import java.util.*;
- class reversing{
- public static void main(String args []){
- int a=23456789,b=0,e=10,c=1,n=0;
- //----------------------------finding its place-----------------------------
- for(;c!=0;){
- c=a/e;
- e=e*10;
- }
- if(c==0){
- e=e/100;
- }
- //-----------------------reversing the number-------------------------------
- c=10;
- if(e>=10){
- for(;e>=1;){
- b=a%c;
- a=a/c;
- System.out.println("b="+b+"a="+a+"c="+c);
- b=b*e;
- n=n+b;
- System.out.println("b="+b+"c="+c+"n"+n);
- e=e/10;
- System.out.println("e"+e);
- }}
- else{
- b=a/1;
- n=n+b;
- }
- System.out.println("final"+n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement