-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort_med_helper.c
80 lines (73 loc) · 1.66 KB
/
sort_med_helper.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sort_med_helper.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: zessadqu <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/05 14:32:04 by zessadqu #+# #+# */
/* Updated: 2022/06/05 14:34:56 by zessadqu ### ########.fr */
/* */
/* ************************************************************************** */
#include "check_header.h"
int smalest_pos(t_nums *a)
{
long min;
int index;
t_nums *tmp;
index = 0;
tmp = a;
min = INT_MAX;
while (tmp)
{
if (min > tmp->num)
min = tmp->num;
tmp = tmp->next;
}
while (a)
{
if (a->num == min)
return (index);
index++;
a = a->next;
}
return (index);
}
int find_min(t_nums *a)
{
int min;
int index;
t_nums *tmp;
index = 0;
tmp = a;
min = INT_MAX;
while (tmp)
{
if (min > tmp->moves)
min = tmp->moves;
tmp = tmp->next;
}
while (a)
{
if (a->moves == min)
return (index);
a = a->next;
index++;
}
return (index);
}
int find_big_pos(t_nums *a)
{
long biggest;
int index;
index = 0;
biggest = find_big(a);
while (a)
{
if (a->num == biggest)
return (index);
index++;
a = a->next;
}
return (index);
}