#include <stdio.h>
int decim(int n) {
int i = 1,a;
int octal = 0;
if(n<=7) {
octal=n;
}
else {
while(n>=8) {
a=n%8;
n=n/8;
octal = octal + a * i;
i*= 10;
}
n=n%8;
octal = octal + n * i;
}
return octal;
}
int main() {
int n,octal;
printf("Informe um numero decimal:");
octal=decim(n);
printf(" o numero octal eh: %d\n",octal
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgZGVjaW0oaW50IG4pIHsKICAgIGludCBpID0gMSxhOwogICAgaW50IG9jdGFsID0gMDsKCgogICAgaWYobjw9NykgewogICAgICAgIG9jdGFsPW47CiAgICB9CgogICAgZWxzZSB7CgogICAgICAgIHdoaWxlKG4+PTgpIHsKICAgICAgICAgICAgYT1uJTg7CiAgICAgICAgICAgIG49bi84OwogICAgICAgICAgICBvY3RhbCA9IG9jdGFsICsgYSAqIGk7CiAgICAgICAgICAgIGkqPSAxMDsKICAgICAgICB9CiAgICAgICAgbj1uJTg7CiAgICAgICAgb2N0YWwgPSBvY3RhbCArIG4gKiBpOwoKICAgIH0KCiAgICByZXR1cm4gb2N0YWw7Cgp9CgoKaW50IG1haW4oKSB7CiAgICBpbnQgbixvY3RhbDsKCiAgICBwcmludGYoIkluZm9ybWUgdW0gbnVtZXJvIGRlY2ltYWw6Iik7CiAgICBzY2FuZigiJWQiLCZuKTsKCiAgICBvY3RhbD1kZWNpbShuKTsKCiAgICBwcmludGYoIiBvIG51bWVybyBvY3RhbCBlaDogJWRcbiIsb2N0YWwpOwoKCgogICAgcmV0dXJuIDA7Cn0K