Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
codetility CyclicRotation
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { //Your code goes here Console.WriteLine("Begin 2nd codetility CyclicRotation for:"); int [] A = {10, 11, 12, 13, 14}; int k = 3; foreach (int x in A) { Console.Write(x + ", "); } Console.WriteLine("\nrotated {0} Times",k); var s = new Solution(); A = s.solution(A, k); foreach (int x in A) { Console.Write(x + ", "); } } } public class Solution { public int[] solution(int[] A, int K) { Console.WriteLine("And the answer is:"); for (int x = 1; x<K+1; x++){ rotate(A); } return A; } public int[] rotate(int[] A) { for (int x = 0; x<A.Length; x++){ var temp = A[x]; A[x] = A[A.Length-1]; A[A.Length-1] = temp; } return A; } } }
run
|
edit
|
history
|
help
0
Pascal's triangle
time
Tttt
Explanation about Aggregate method in C#
learning
I know it's a bit combersome, but it's my first attempt.
2.2 gz
438935
Encode URl C#
List, Object, Classes, Function