题目:十进制转换三进制。
分析:字符串处理,储存余数,逆向输出。
#include <stdio.h>
#include <stdlib.h>
int base_3[100];
int main()
{
int n;
while ( scanf("%d",&n) && n >= 0 ) {
int count = 0;
do {
base_3[count ++] = n%3;
n /= 3;
}while ( n );
printf("%d",base_3[-- count]);
while ( count > 0 )
printf("%d",base_3[-- count]);
printf("\n");
}
return 0;
}