Click Here to see the problem detail.
Solution
There is nothing to explain. See source code.
Source Code
#include<stdio.h> void ternary(int n) { if(n) { ternary(n/3); putchar(n%3+'0'); } } int main() { int x; while(1) { scanf("%d",&x); if(x==-1) break; else if(x==0) printf("0\n"); else ternary(x); printf("\n"); } return 0; }
Next Previous