Advertisement
Guest User

Untitled

a guest
Feb 25th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <stdio.h>
  2. void sort(int* ,int*, int*);
  3. void swap(int* ,int*);
  4. int main()
  5. {
  6. int min,mid,max;
  7. printf("Please enter three numbers to sort:");
  8. scanf("%d%d%d",&min,&mid,&max);
  9. sort(&min,&mid,&max);
  10. printf("sorted : %d %d %d\n",min,mid,max);
  11. }
  12. void swap(int* a, int* b)
  13. {
  14. int tmp = *a;
  15. *a = *b;
  16. *b = tmp;
  17. }
  18. void sort(int* pmin, int* pmid ,int* pmax)
  19. {
  20. if(*pmin > *pmid)///?אני יכול כבר בשלב הזה להוריד את הכוכביות?
  21. swap(pmin,pmid);
  22. if(*pmid > *pmax)
  23. swap(pmid,pmax);
  24. if(*pmin > *pmid)
  25. swap(pmin,pmid);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement