Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# rotate sum array

int[] arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
int rotate = int.Parse(Console.ReadLine());
int[] sumResult = new int[arr.Length];

for (int i = 0; i < rotate; i++)
{
  int lastElement = arr[arr.Length - 1];

  for (int j = arr.Length - 1; j > 0; j--)
  {
    arr[j] = arr[j - 1];
  }
  arr[0] = lastElement;

  for (int w = 0; w < arr.Length; w++)
  {
    sumResult[w] += arr[w];
  }
}
Console.WriteLine(string.Join(" ", sumResult));
Comment

PREVIOUS NEXT
Code Example
Csharp :: tmpro pageCount update 
Csharp :: taskcontinuationoptions.onlyonfaulted 
Csharp :: c# catch multiple exceptions at once 
Csharp :: c# alert message 
Csharp :: check null type 
Csharp :: Display the elements in an array one at a time using getkeydown in unity 
Csharp :: unity generate random offset position around a gameobject 
Csharp :: large blank file C# 
Csharp :: how to move an object with addforce 
Csharp :: how to change the scale of a gameobject in unity 
Csharp :: Difference between PhotonNetwork.Ismasterclient and PhotonView.ismasterclient 
Csharp :: c# uint 
Csharp :: how do make internet 
Csharp :: antlr c# errors 
Csharp :: C# change to different form 
Csharp :: startup c# class winform 
Csharp :: c# convert linq jValue to int 
Csharp :: expander vertical wpf 
Csharp :: unity sprite blurry when far 
Csharp :: process run teamviewer address parametr c# 
Csharp :: IOS app crashing on ios 15 unity 
Csharp :: c# read key without writing 
Csharp :: ascx access parent master page 
Csharp :: how to handle array getter setter in c# of string type 
Csharp :: replace bar c# 
Csharp :: Close Form After fixed time 
Csharp :: unity roam, chase, attack states 
Csharp :: how to make dobuble jump unity 2d 
Csharp :: webtest fullscreen extend window maximize 
Csharp :: Fibonacci Ienumerable 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =