fork(1) download
  1. #include <stdio.h>
  2.  
  3. void maxmin(int prob1, int prob2, int prob3, int *max, int *min);
  4.  
  5. int main() {
  6. int x, y, z;
  7.  
  8. if (scanf("%d %d %d", &x, &y, &z) != 3) {
  9. printf("n/a");
  10. return 1;
  11. }
  12.  
  13. // Check for trailing characters
  14. int c;
  15. do {
  16. c = getchar();
  17. } while (c == ' ' || c == '\t'); // Skip any remaining spaces or tabs
  18.  
  19. if (c != '\n' && c != EOF) {
  20. printf("n/a");
  21. return 1;
  22. }
  23.  
  24. int max, min;
  25. maxmin(x, y, z, &max, &min);
  26.  
  27. printf("%d %d", max, min);
  28.  
  29. return 0;
  30. }
  31.  
  32. void maxmin(int prob1, int prob2, int prob3, int *max, int *min) {
  33. *max = *min = prob1;
  34.  
  35. if (prob2 > *max) *max = prob2;
  36. if (prob2 < *min) *min = prob2;
  37.  
  38. if (prob3 > *max) *max = prob3;
  39. if (prob3 < *min) *min = prob3;
  40. }
Success #stdin #stdout 0.01s 5280KB
stdin
1 2 3
stdout
3 1