3119. 排序

10185101141

弱智解法——

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;
}

583449479

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’:’ ‘);
}

你当前正在回复 博客/题目
存在问题!