-
Notifications
You must be signed in to change notification settings - Fork 1
/
fill_array.cpp
61 lines (54 loc) · 954 Bytes
/
fill_array.cpp
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
#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int>> vi;
typedef vector<int> v;
void printArr(vi arr)
{
cout << " hello " <<endl;
int i = 0;
int k = 0;
while (i < arr.size())
{
while (k < arr[i].size()){
cout << arr[i][k];
k++;
}
i++;
}
}
int fillArray(int arr[], int n, int len)
{
v base;
vi big;
int i = 0;
int bigLen = 0;
int j = 0;
int dif = len - n;
while (i < n)
{
base.push_back(arr[i]);
i++;
}
while (j < dif)
{
big.push_back(base);
bigLen += big[j].size();
if (len - bigLen == 1)
{
big.push_back({base[j]});
}
else
{
continue;
}
j++;
}
printArr(big);
}
int main()
{
cout << " hello " <<endl;
int numbers[5] = {1,2,3,4,5};
fillArray(numbers,3,5);
return 0;
}