I have a 10 x 1 array made with 1s and 0s like below:
1 | |
---|---|
1 | 1 |
2 | 0 |
3 | 1 |
4 | 1 |
5 | 1 |
6 | 0 |
7 | 1 |
8 | 0 |
9 | 0 |
10 | 1 |
Using for loop, how can I count only 1s from the above array and create a new array? I'm not sure how to explain this in words. Basically, I want to create something like this:
1 | |
---|---|
1 | 1 |
2 | 3 |
3 | 4 |
4 | 5 |
5 | 7 |
6 | 10 |