fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int x,y,z,t;
  5. printf("\n请输入三个数字:\n");
  6. scanf("%d%d%d",&x,&y,&z);
  7.  
  8. if ( x>y ) {
  9. /*交换x,y的值*/
  10. t=x; x=y; y=t;
  11. }
  12.  
  13. if ( x>z ) {
  14. /*交换x,z的值*/
  15. t=z; z=x; x=t;
  16. }
  17.  
  18. if ( y>z ) {
  19. /*交换z,y的值*/
  20. t=y; y=z; z=t;
  21. }
  22.  
  23. printf("从小到大排序: %d %d %d\n",x,y,z);
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 5320KB
stdin
5  9  6
stdout
请输入三个数字:
从小到大排序: 5 6 9