Pruthvi Patel

Pruthvi Patel

  • NA
  • 129
  • 23.5k

Please Help me to do this Sum and split array like this.

Dec 18 2016 12:56 AM
arr[]={1,3,2,4,6,7,8,9,10, 11,12,16,5,8,7,8,4,6};
split=2; // the arr[] will be divide in 2(no of splits) parts each with equal elements split=1,2,3...n
skip=2; // skip is no of element to be skipped. skip=1,2,3...n
size of res[] should be accordingly.
then
res[0]=15 //1+4+8
res[1]=18//3+6+9
res[2]=19 //2+7+10
res[3]=24 //11+5+8
res[4]= 24 //12+8+4
res[5]= 29//16+7+6
and like wise split can be 1 to n.
arr[]={1,2,3...n} elements
This should be dynamically.
Please help me to do this.
Thanks

Answers (1)