-
Notifications
You must be signed in to change notification settings - Fork 0
/
Controle.c
59 lines (51 loc) · 1.01 KB
/
Controle.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
#include <stdio.h>
#include <stdlib.h>
typedef struct Diagonale
{
int len;
int *data;
} Diagonale_t;
typedef struct Matrix
{
int len;
int **mat;
} Matrix_t;
Diagonale_t Get_Dn(Matrix_t mat, int n)
{
Diagonale_t resp;
resp.len = mat.len - n;
resp.data = (int *)malloc(sizeof(int) * resp.len);
for (int i = 0; i < resp.len; i++)
resp.data[i] = mat.mat[i + n][i];
return resp;
}
void Longest(int arr[], int n)
{
int pos = 0, len;
int max_len = 1;
for (int i = 0; i < n; i++)
{
len = 1;
for (int j = i + 1; j < n; j++)
{
if (arr[i] == arr[j])
len++;
else
{
if (max_len < len)
{
max_len = len;
pos = i;
break;
}
else
break;
}
}
}
printf("position = %d\nlongueur = %d", pos, max_len);
}
int main()
{
return EXIT_SUCCESS;
}