-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathminmax.c
executable file
·38 lines (34 loc) · 1.48 KB
/
minmax.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/***************************************************************************
minmax.c - get min and max
-------------------
begin : Sat Mar 9 09:51:02 GMT 2002
copyright : (C) 2002 by Gwyndaf Evans
email : gwyndaf@gwyndafevans.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "chooch.h"
int minmax(int n, float *fArray, float *fMin, float *fMax)
{
extern int verbose;
int i;
*fMin = 10000000;
*fMax = -10000000;
for (i = 0; i < n; i++) {
*fMin = (fArray[i] < *fMin) ? fArray[i] : *fMin;
*fMax = (fArray[i] > *fMax) ? fArray[i] : *fMax;
}
if(verbose>2)printf("In minmax: %f %f\n", *fMin, *fMax);
return EXIT_SUCCESS;
}