Search
 
SCRIPT & CODE EXAMPLE
 

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;
  }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# HttpUtility not found / missing C# 
Csharp :: windows forms webbrowser goforward 
Csharp :: c# entity mvc get user from razor layout 
Csharp :: mvc form name 
Csharp :: windows forms change double buffer during runtime 
Csharp :: nullable IList to List 
Csharp :: 40/100 percentage 
Csharp :: #movement speed c 
Csharp :: dictionary plus generic class c# 
Csharp :: data types of document in asp dot net frame work 
Csharp :: C# program to find sum of array elements 
Csharp :: Toggle value change 
Csharp :: drop column with code first asp.net core 
Csharp :: mysql executeScalar only if successful 
Csharp :: c sharp right rotation 
Csharp :: C# Search in JSON without deserialization 
Csharp :: remove multiple element on list from index a to b C# 
Csharp :: C# Relational Operators 
Csharp :: convert excel to datatable using epplus 
Csharp :: clickable table row asp.net core cursor 
Csharp :: save current dir shell 
Csharp :: get child index unity 
Csharp :: c# uri to string 
Csharp :: UPA Error 
Csharp :: Focus on last entry in listbox 
Csharp :: c# get first and last day of current month 
Csharp :: how to disable scale anti-aliasing in monogame 
Csharp :: Game of two stack c# 
Csharp :: Devexpress MVC Gridview BinaryImage Picture 
Csharp :: asp.net stop page jumping to top on click 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =