2
Reply

Sum and Split array like below.

Pruthvi Patel

Pruthvi Patel

Dec 20 2016 10:33 AM
259
Please Please Reply.

arr[]={1,3,2,4,6,7,8,9,10, 11,12,16,5,8,7,8,4,6, 8,9,10, 11,12,16,2,4, 5};

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.

group=3 // vary between 1,2,3..n

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

res[6]=21 //8+11+2

res[7]=25 //9+12+4

res[8]=31 //10+16+5

and like wise split can be 1 to n.

arr[]={1,2,3...n} elements

 

Answers (2)