注意0和1的情况。经典题,简单题。
附ac代码:
#include <stdio.h> int a[20]; int main(){ int n, i, count; while(scanf("%d", &n) == 1){ i = 9; count = 0; if(n == 0){ printf("10\n"); continue; } if(1 == n){ printf("1\n"); continue; } while(i > 1){ if(n % i == 0){ a[count++] = i; n /= i; continue; } --i; } if(n != 1) printf("-1\n"); else{ while(count--) printf("%d", a[count]); printf("\n"); } } return 0; }
原文:http://blog.csdn.net/chang_mu/article/details/19286721