數值轉換(10to8)

#include
#include <math.h>
#include <stdlib.h>
void tentoeight(n){
    int a[10000];
    int res=n;
    int i=0,j;
    while(res!=0){
        a[i]=res%8;
        res=res/8;
        i++;
    }
    for(j=i-1;j>=0;j--){
        printf("%d",a[j]);}
    printf("\n");
}
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF){
       tentoeight(n);
    }
    return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章