程序代码:
#include<stdio.h> int store[32] = {0}; int foo() { int i, j, k, a[10] = {0}, flag = 1, result = 0; scanf("%d",&i); i<0?(i*=-1,flag=-1):1; for (j=0; i>0; store[j]=i%10,i/=10,a[store[j++]]++); for (k=1; k<10; k++) for (j=0; j<a[k]; j++) result = 10*result+k; return flag*result; } void main() { printf("result = %d\n",foo()); }
向杨大哥学习~