#include <stdio.h> int main() { ??? int a[100]; ??? int i,n,j,t; ??? int c[100]; ??? while (scanf("%d",&n)!=EOF&&n!=0) ??? { ?????? for (i=0;i<n;i++) ??? { ??????? scanf("%d",&a[i]); ??????? c[i]=a[i]; ??? } ??? int b[100]={0}; ??? int k=0,m=0; ??? for (i=0;i<n;i++) ??? { ?????? while (a[i]>0) ????? { ??????? k=a[i]%10; ??????? a[i]=a[i]/10; ??????? b[i]+=k; ????? } ??? }
??? for (j=1;j<n;j++) ??? { ??????? for (i=0;i<n-j;i++) ??????? { ??????????? if (b[i]>b[i+1]) ??????????? {
??????????????? m=b[i]; ??????????????? b[i]=b[i+1]; ??????????????? b[i+1]=m; ??????????????? t=c[i]; ??????????????? c[i]=c[i+1]; ??????????????? c[i+1]=t; ??????????? } ??????? } ??? } ??? for (i=0;i<n;i++) ??? { ??????? printf("%d ",c[i]); ??? } ??? printf("\n"); ??? }
}
|