Pruthvi Patel

Pruthvi Patel

  • NA
  • 129
  • 23.5k

Split and sum array element like below.

Nov 6 2016 6:22 AM
arr[]={1,3,2,4,6,7,8,8};
split=2; // the arr[] will be divide in 2(no of splits) parts each with equal elements
skip=1; //  skip is no of element to be skipped.
size of res[] should be accordingly. 
then
res[0]=3 //1+2 
res[1]=7 //3+4
res[2]=14 //6+8
res[3]=15 //7+8 
 
split=1,2,3...n
skip=1,2,3...n
arr[]={1,2,3...n} elements
 
This should be dynamically.
Please help me to do this.
Thanks 

Answers (5)