弱智解法——
int main() { int a,b,c,tmp; scanf(“%d %d %d”,&a,&b,&c); if(a>b){ tmp=a; a=b; b=tmp; } if(a>c){ tmp=a; a=c; c=tmp; } if(b>c){ tmp=b; b=c; c=tmp; } printf(“%d %d %d\n”,a,b,c); return 0; }
ac
int cmp(const void a,const void b){ return (int )a-(int )b; }
int main() { int num[3]; scanf(“%d%d%d”,&num[0],&num[1],&num[2]); qsort(num,3,sizeof(num[0]),cmp); int i; for(i=0;i<3;i++) printf(“%d%c”,num[i],i==2?’\n’:’ ‘); }
弱智解法——
include
int main()
{
int a,b,c,tmp;
scanf(“%d %d %d”,&a,&b,&c);
if(a>b){
tmp=a;
a=b;
b=tmp;
}
if(a>c){
tmp=a;
a=c;
c=tmp;
}
if(b>c){
tmp=b;
b=c;
c=tmp;
}
printf(“%d %d %d\n”,a,b,c);
return 0;
}
ac
include
include
int cmp(const void a,const void b){
return (int )a-(int )b;
}
int main()
{
int num[3];
scanf(“%d%d%d”,&num[0],&num[1],&num[2]);
qsort(num,3,sizeof(num[0]),cmp);
int i;
for(i=0;i<3;i++)
printf(“%d%c”,num[i],i==2?’\n’:’ ‘);
}