Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2. void swap(int *a, int *b)
  3. {
  4. int temp = *a;
  5. *a = *b;
  6. *b = temp;
  7. }
  8. int main()
  9. {
  10. int n1, n2;
  11. scanf("%d%d",&n1, &n2);
  12. if (n1 > n2) swap(&n1, &n2);
  13. while(scanf("%d",&check) == 1 && check != -1)
  14. {
  15. if (check > 0)
  16. {
  17. if (n2 < 0) n2 = check;
  18. else if (n1 < 0) n1 = check;
  19. else if (check < n1)
  20. {
  21. n2 = n1;
  22. n1 = check;
  23. }
  24. else if (check < n2)
  25. {
  26. n2 = check;
  27. }
  28. }
  29. }
  30. printf("%d %d\n", n1, n2);
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement