Pruthvi Patel

Pruthvi Patel

  • NA
  • 129
  • 23.2k

Split an array and do operation like below

Nov 16 2016 1:19 AM
arr[]={1,2,3,4,5,6,2,3,5,4,3,6,7,8,9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
spliter=2 // this will divide an array in to two equal parts before null element(0) found this means it will consider arr[]={1,2,3,4,5,6,2,3} and it will split an array in two equal parts arr[]={1,2,3,4,5,6,2,3,5,4,3,6,7,8,9,1}.if spliter=3 then three equal parts and likewise. spliter=1,2,3...n.and perform following operations.
skip=1 // this will skip an element skip=1,2,3...n
res[0]= 11 // 1+3+5+2
res[1]= 15 // 2+4+6+3
res[2]= 24 //5+3+7+9
res[3]= 19 //4+6+8+1 //res[index] can be vary as input spliter is vary.
This all should be dynamically.
Please help me to do this.
thanks.
Please Please reply me if possible as early as because its urgent.

Answers (1)