标签:ring print 数位 ted oid 展开 sys bsp change
1 import java.util.Scanner; 2 3 public class Change { 4 5 public static void main(String[] args) { 6 // TODO Auto-generated method stub 7 Scanner cin = new Scanner(System.in); 8 System.out.print("输入待转换的数和其进制:"); 9 int OldNum = cin.nextInt();//待转换成10进制的数 10 int x = cin.nextInt();//待转换数的进制 11 int num = change(OldNum, x); 12 System.out.println(num); 13 } 14 public static int change(int n, int x) { 15 int num = 0; 16 int k = 1; 17 while(n!=0) { 18 int m = n % 10;//取最后一位数 19 num += m * k; 20 n = n / 10; 21 k *= x; 22 } 23 return num; 24 } 25 }
标签:ring print 数位 ted oid 展开 sys bsp change
原文地址:https://www.cnblogs.com/forever-snow/p/9061604.html