-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
55 lines (40 loc) · 967 Bytes
/
main.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
#include <stdio.h>
void subSequences(int v[], int n);
int main() {
int n, m;
int i = 0;
printf("Please write the number of elements for the vector\n");
scanf("%d", &n);
int v[n];
printf("Values:\n");
while (i < n) {
scanf("%d", &m);
v[i] = m;
i++;
}
subSequences(v, n);
return 0;
}
void subSequences(int v[], int n) {
int counter = 0;
for (int i = 0; i < n; i++) {
if (v[i] != 0)
counter++;
if (v[i] == 0) {
if (counter >= i) {
for (int s = 0; s < i; s++) {
printf("%d", v[s]);
}
counter = 0;
printf("\n");
}
if (counter < i) {
for (int s = i - counter; s < i; s++) {
printf("%d", v[s]);
}
counter = 0;
printf("\n");
}
}
}
}