공부집

진법 변환 본문

코딩문제/코딜리티

진법 변환

ikemen_hk 2017. 12. 17. 21:40

//not : 변환시킬 진법

//val : 십진수 값


public static int notation(int not,int val){

         int result = 0;

         int []res;   

         res = new int[100];

         int count = 0;

         

         for(int i=0; val>0 ;i++){

            res[i] = val%not;

            val = val/not;

            count++;

         }

         

         for(int i=count-1; 0<=i ;i--){

            result *= 10;

            result += res[i];

         }

         

         return result;   

    }

Comments