四個數字 從小排到大 由大排到小
#include <stdio.h> int main(){ int a,b,c,d; int temp=0; scanf("%d%d%d%d",&a,&b,&c,&d); if (a>b){ temp =a; a=b; b=temp; } if (a>c){ temp =a; a=c; c=temp; } if (a>d){ temp =a; a=d; d=temp; } if (b>a){ temp =b; b=a; a=temp; } if (b>c){ temp =b; b=c; c=temp; } if (b>d){ temp =b; b=d; d=temp; } if (c>a){ temp =c; c=a; a=temp; } if (c>b){ temp =c; c=b; b=temp; } if (c>d){ temp =c; c=d; d=temp; } if (d>a){ temp =d; d=a; a=temp; } if (d>b){ temp =d; d=b; b=temp; } if (d>c){ temp =d; d=c; c=temp; } printf("%d%d%d%d\n",a,b,c,d); if (a<b){ temp =a; a=b; b=temp; } if (a<c){ temp =a; a=c; c=temp; } if (a<d){ temp =a; a=d; d=temp; } if (b<a){ temp =b; b=a; a=temp; } if (b<c){ temp =b; b=c; c=temp; } if (b<d){ temp =b; b=d; d=temp; } if (c<a){ temp =c; c=a; a=temp; } if (c<b){ temp =c; c=b; b=temp; } if (c<d){ temp =c; c=d; d=temp; } if (d<a){ temp =d; d=a; a=temp; } if (d<b){ temp =d; d=b; b=temp; } if (d<c){ temp =d; d=c; c=temp; } printf("%d%d%d%d",a,b,c,d); }
文章標籤
全站熱搜