#include <stdio.h>
void decimal_to_octal(int num) {
int result[15] = {};
int i = 0, j = 0;
if(num >= 8) {
printf("Decimal: %d -> Octal: ", num
);
while(num >= 8) {
result[i++] = num % 8;
num = num / 8;
}
result[i] = num;
for(j = i; j >= 0; j--) {
}
} else {
printf("Decimal: %d -> Octal: %d\n", num
, num
); }
}
int main(void) {
decimal_to_octal(7);
decimal_to_octal(8);
decimal_to_octal(10);
decimal_to_octal(568);
decimal_to_octal(3578);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIGRlY2ltYWxfdG9fb2N0YWwoaW50IG51bSkgewoJaW50IHJlc3VsdFsxNV0gPSB7fTsKCWludCBpID0gMCwgaiA9IDA7CgkKCWlmKG51bSA+PSA4KSB7CgkJcHJpbnRmKCJEZWNpbWFsOiAlZCAtPiBPY3RhbDogIiwgbnVtKTsKCQkKCQl3aGlsZShudW0gPj0gOCkgewoJCQlyZXN1bHRbaSsrXSA9IG51bSAlIDg7CgkJCW51bSA9IG51bSAvIDg7CQoJCX0KCQlyZXN1bHRbaV0gPSBudW07CgkJCgkJZm9yKGogPSBpOyBqID49IDA7IGotLSkgewoJCQlwcmludGYoIiVkIiwgcmVzdWx0W2pdKTsKCQl9CgkJcHJpbnRmKCJcbiIpOwoJfSBlbHNlIHsKCQlwcmludGYoIkRlY2ltYWw6ICVkIC0+IE9jdGFsOiAlZFxuIiwgbnVtLCBudW0pOwoJfQp9CgppbnQgbWFpbih2b2lkKSB7CgkKCWRlY2ltYWxfdG9fb2N0YWwoNyk7CglkZWNpbWFsX3RvX29jdGFsKDgpOwoJZGVjaW1hbF90b19vY3RhbCgxMCk7CglkZWNpbWFsX3RvX29jdGFsKDU2OCk7CglkZWNpbWFsX3RvX29jdGFsKDM1NzgpOwoJcmV0dXJuIDA7Cn0K