-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_max.c
executable file
·51 lines (48 loc) · 1.64 KB
/
ft_max.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_max.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/16 22:20:06 by akharrou #+# #+# */
/* Updated: 2019/03/16 22:32:48 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
/*
** NAME
** ft_max -- get the maximum value of a vector.
**
** SYNOPSIS
** #include "math_42.h"
**
** int
** ft_max(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 maximum value of the vector
** and returns it.
**
** RETURN VALUES
** Returns the maximum value found in the vector.
*/
int ft_max(int *vector, unsigned int size)
{
unsigned int i;
int max;
if (vector && size > 0)
{
max = vector[0];
i = 0;
while (size > ++i)
max = (vector[i] > max) ? vector[i] : max;
return (max);
}
return (0);
}