回复 8楼 ppfly
#include<stdio.h>
#include<stdlib.h>
void sort(int a[],int n)
{int i,j,t;
for(i=0;i<n-1;i++)
for(j=0;j<n-1-i;j++)
if(a[j]>a[j+1])
{t=a[j];a[j]=a[j+1];a[j+1]=t;}
}
long arrange(long s)
{int d,b[10],i,j=0;
long s1=0;
while(s>0)
{d=s%10;
if(d%2!=0)
b[j++]=d;
s/=10;
}
sort(b,j);
for(i=0;i<j;i++)
s1=s1*10+b[i];
return s1;
}
void main()
{long m,n;
FILE*fp;
if((fp=fopen("1.out","w"))==NULL)
{printf("The file can not open!");exit(0);}
scanf("%ld",&n);
m=arrange(n);
printf("%ld\n",m);
fprintf(fp,"%ld\n",m);
printf("\nMy exam number is:WLJY001\n");
fprintf(fp,"\nMy exam number is:WLJY001\n");
fclose(fp);
getch();
}