-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_min.c
executable file
·51 lines (48 loc) · 1.64 KB
/
ft_min.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
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_min.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <akharrou@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/16 21:49:27 by akharrou #+# #+# */
/* Updated: 2019/03/16 22:33:11 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
/*
** NAME
** ft_min -- get the minimum value of a vector.
**
** SYNOPSIS
** #include "math_42.h"
**
** int
** ft_min(int *vector, unsigned int size);
**
** PARAMETERS
**
** int *vector Vector containing numbers (of type int).
**
** unsigned int size Size of the vector.
**
** DESCRIPTION
** Iterates through the vector finds the minimum value of the vector
** and returns it.
**
** RETURN VALUES
** Returns the minimum value found in the vector.
*/
int ft_min(int *vector, unsigned int size)
{
unsigned int i;
int min;
if (vector && size > 0)
{
min = vector[0];
i = 0;
while (size > ++i)
min = (vector[i] < min) ? vector[i] : min;
return (min);
}
return (0);
}