Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# fold sum array

int[] sequence = Console.ReadLine().Split().Select(int.Parse).ToArray();

int middleStartIndex = sequence.Length / 4;
int middleEndIndex = middleStartIndex + sequence.Length / 2;

int summingIndex = middleStartIndex - 1;

for (int i = middleStartIndex; i < middleEndIndex; i++)
{
  int sum = sequence[i] + sequence[summingIndex];
  Console.Write($"{sum} ");
  summingIndex--;
  if (summingIndex < 0)
  {
    summingIndex = sequence.Length - 1;
  }
}
Source by github.com #
 
PREVIOUS NEXT
Tagged: #fold #sum #array
ADD COMMENT
Topic
Name
7+6 =