一.八进制转十进制
#include<stdio.h>
#include<math.h>
int main(){
int a,b=0;
int x;
int count=0;
scanf("%d",&a);
while(a!=0){
x=a%10;
a/=10;
b+=x*pow(8,count);
count++;
}
printf("%d\n",b);
return 0;
}
二.十进制转八进制
#include<stdio.h>
#include<math.h>
int main(){
int a,b=0;
int t,i=1;
scanf("%d",&a);
while(a!=0){
t=a%8;
a/=8;
b+=t*i;
i*=10;
}
printf("%d\n",b);
return 0;
}