Merge pull request #400 from khalil2535/master

Thanks for the changes! I maintain this repository only recently.
This commit is contained in:
Christian Bender 2018-04-02 15:06:46 +02:00 committed by GitHub
commit d2c944387e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,28 +1,29 @@
package Java.Conversions;
import java.util.Scanner;
//given a source number , source base, destination base, this code can give you the destination number.
//sn ,sb,db ---> ()dn . this is what we have to do .
public class anytoany {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int sn = scn.nextInt();
int sb = scn.nextInt();
int db = scn.nextInt();
int m=1,dec=0,dn=0;
while(sn!=0)
{
dec=dec+ (sn%10)*m;
m*=sb;
sn/=10;
}
m=1;
while(dec!=0)
{
dn=dn+ (dec%db)*m;
m*=10;
dec/=db;
}
System.out.println(dn);
}
public class AnytoAny {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int sn = scn.nextInt();
int sb = scn.nextInt();
int db = scn.nextInt();
int m = 1, dec = 0, dn = 0;
while (sn != 0) {
dec = dec + (sn % 10) * m;
m *= sb;
sn /= 10;
}
m = 1;
while (dec != 0) {
dn = dn + (dec % db) * m;
m *= 10;
dec /= db;
}
System.out.println(dn);
}
}