median.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. $Log$
  3. Revision 1.15 2004/06/26 03:50:14 markster
  4. Merge source cleanups (bug #1911)
  5. Revision 1.14 2003/02/12 13:59:15 matteo
  6. mer feb 12 14:56:57 CET 2003
  7. Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  8. mer feb 12 14:56:57 CET 2003
  9. Revision 1.2 2000/01/05 08:20:39 markster
  10. Some OSS fixes and a few lpc changes to make it actually work
  11. * Revision 1.1 1996/08/19 22:31:31 jaf
  12. * Initial revision
  13. *
  14. */
  15. /* -- translated by f2c (version 19951025).
  16. You must link the resulting object file with the libraries:
  17. -lf2c -lm (in that order)
  18. */
  19. #include "f2c.h"
  20. #ifdef P_R_O_T_O_T_Y_P_E_S
  21. extern integer median_(integer *d1, integer *d2, integer *d3);
  22. #endif
  23. /* ********************************************************************* */
  24. /* MEDIAN Version 45G */
  25. /* $Log$
  26. * Revision 1.15 2004/06/26 03:50:14 markster
  27. * Merge source cleanups (bug #1911)
  28. *
  29. * Revision 1.14 2003/02/12 13:59:15 matteo
  30. * mer feb 12 14:56:57 CET 2003
  31. *
  32. * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
  33. * mer feb 12 14:56:57 CET 2003
  34. *
  35. * Revision 1.2 2000/01/05 08:20:39 markster
  36. * Some OSS fixes and a few lpc changes to make it actually work
  37. *
  38. * Revision 1.1 1996/08/19 22:31:31 jaf
  39. * Initial revision
  40. * */
  41. /* Revision 1.2 1996/03/14 22:30:22 jaf */
  42. /* Just rearranged the comments and local variable declarations a bit. */
  43. /* Revision 1.1 1996/02/07 14:47:53 jaf */
  44. /* Initial revision */
  45. /* ********************************************************************* */
  46. /* Find median of three values */
  47. /* Input: */
  48. /* D1,D2,D3 - Three input values */
  49. /* Output: */
  50. /* MEDIAN - Median value */
  51. integer median_(integer *d1, integer *d2, integer *d3)
  52. {
  53. /* System generated locals */
  54. integer ret_val;
  55. /* Arguments */
  56. ret_val = *d2;
  57. if (*d2 > *d1 && *d2 > *d3) {
  58. ret_val = *d1;
  59. if (*d3 > *d1) {
  60. ret_val = *d3;
  61. }
  62. } else if (*d2 < *d1 && *d2 < *d3) {
  63. ret_val = *d1;
  64. if (*d3 < *d1) {
  65. ret_val = *d3;
  66. }
  67. }
  68. return ret_val;
  69. } /* median_ */