将十进制转换为任意进制的数字:
import java.util.Scanner;

public class test1 {
    
    test1(){
        int x,y,integer_Num,remainder_Num,last;    //x表示要转成的进制,y表示要转换的十进制数值,last表示最终结果
        Scanner reader=new Scanner(System.in);
        System.out.println("请输入要转换成的进制:");
        x=reader.nextInt();
        System.out.println("请输入要转换的十进制数值:");
        y=reader.nextInt();
        integer_Num=y/x;
        remainder_Num=y%x;
        last=integer_Num*10+remainder_Num; 
    System.out.println("转换得到的数值是:"+last); 
  } 
    public static void main(String args[]){
        test1 test11=new test1();
     }
 }

 

posted on 2014-05-25 17:08  mosquito_real  阅读(336)  评论(0编辑  收藏  举报