Advertisement
LuongIT

min,max,sap xep

Jul 24th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. //Tim max, min, va sap xep 3 so a,b,c//
  2. #include <stdio.h>
  3. #define MAX(x,y) (x>y)?x:y
  4. #define MIN(x,y) (x<y)?x:y
  5. int main()
  6. {
  7. int a,b,c,sg;
  8. printf(Nhap a,b,c: \n);scanf("%d%d%d",&a,&b,&c); //Nhap a,b,c.
  9. printf("So lon nhat la: %d",MAX(MAX(a,b),c)); //MAX.
  10. printf("So nho nhat la: %d",MIN(MIN(a,b),c)); //MIN.
  11. sg=a+b+c-(MAX(MAX(a,b),c)+MIN(MIN(a,b),c)); //Tinh so giua trong day sap xep.
  12. printf("Sap xep tang dan: %d, %d, %d",MIN(MIN(a,b),c),sg,MAX(MAX(a,b),c));
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement