Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <stdio.h>
  2. void min(int a, int b, int *menora, int *menorb) {
  3. *menora = 999999999;
  4. *menorb = 999999999;
  5. if (a <= *menora){
  6. if(b <= *menorb){
  7. *menora = a;
  8. *menorb = b;
  9. }
  10. }
  11. }
  12.  
  13. void max(int a, int b, int *maiora, int *maiorb){
  14. *maiora = -999999999;
  15. *maiorb = -999999999;
  16. if (a >= *maiora){
  17. if (b >= *maiorb){
  18. *maiora = a;
  19. *maiorb = b;
  20. }
  21. }
  22. }
  23.  
  24.  
  25. int main(){
  26. int n, i, menora, menorb, maiora, maiorb, a, b;
  27. scanf("%d", &n);
  28. for(i=0;i<n;i++){
  29. scanf("%d %d", &a, &b);
  30. min(a, b, &menora, &maiorb);
  31. max(a, b, &maiora, &maiorb);
  32. }
  33. printf("min = (%d, %d); max = (%d,%d)", menora,maiora,menorb,maiorb);
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement