arr[]={1,2,3,4,5,6,6,7,6,5,4,3,7,8,8,8,4,3,2,8....n}
split=2
sum=2
then the result array should be like this.
res[0]=47 //1+2+5+6+6+5+7+8+4+3
res[1]=53 //3+4+6+7+4+3+8+8+2+8
Please help me to do this.
Know the answer? Post it. Somebody with the same question will find it here.
Midhun TpRank #388 · 6.5K reputationPosted Nov 2, 2016, 9:11 PM EDT
Rajeev PunhaniRank #551 · 4.4K reputationPosted Oct 31, 2016, 10:55 AM EDT
If the above solution is helpful then,accept the answer.
Manas MohapatraRank #182 · 13.2K reputationPosted Oct 31, 2016, 11:24 AM EDT
Tharu Manickavasagar9 reputationPosted Oct 31, 2016, 7:11 AM EDT
Tharu Manickavasagar9 reputationPosted Nov 1, 2016, 11:30 PM EDT
Rajeev PunhaniRank #551 · 4.4K reputationPosted Nov 2, 2016, 9:19 AM EDT
Ifour Hiren61 reputationPosted Nov 2, 2016, 9:53 PM EDT
{
if (args != null)
{
int argument =Convert.ToInt32(args[0]);
int[] arr = { 1, 2, 3, 4, 5, 6, 6, 7, 6, 5, 4, 3, 7, 8, 8, 8, 4, 3, 2, 8 };
int index = 0;
int[] sumarry= new int[argument];
while (index < arr.Length)
{
for (int i = 0; i < argument; i++)
{
sumarry[i] += arr.Skip(index).Take(argument).Sum();
index += argument;
}
}
for (int i = 0; i < argument; i++)
{
Console.WriteLine(sumarry[i]);
}
}
}
above code helps you to make it working.
Pruthvi Patel138 reputationPosted Oct 31, 2016, 7:15 PM EDT
Pruthvi Patel138 reputationPosted Nov 1, 2016, 1:12 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts