static void Main(string[] args) { SquareArray squareArr = new SquareArray(); List <int> array = new List <int>(); List <int> squarredArray = new List <int>(); Console.Write("Enter array size: "); int arrSize = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < arrSize; i++) { Console.Write("Enter [" + (i + 1) + "] value: "); int curArr = Convert.ToInt32(Console.ReadLine()); array.Add(curArr); } Console.Write("\n\n"); squarredArray = squareArr.ArrToSquare(array); int cnt = 0; foreach (var item in squarredArray) { // Console.Write(item + " "); cnt++; Console.WriteLine("Squarred [" + cnt + "] value: " + item); } }
static void Main(string[] args) { string input; int size; int[,] array = null; do { Console.WriteLine("======================= MENU ======================="); Console.WriteLine("'new' to create a new array."); Console.WriteLine("'print' to print the created array."); Console.WriteLine("'trans' if you want to transpose the created array."); Console.WriteLine("'upper' to form an upper triangle matrix from the created array."); Console.WriteLine("'lower' to from a lower triangle matrix from the created array."); Console.WriteLine("'end' to finish working with the app."); input = Console.ReadLine().ToLower(); if (input.Equals("new")) { Console.Write("Enter the size of the square array: "); size = int.Parse(Console.ReadLine()); array = SquareArray.Create(size); } else if (input.Equals("print")) { if (array != null) { PrintSquareArray(array); } else { Console.WriteLine("You haven't created any arrays yet!"); } } else if (input.Equals("trans")) { SquareArray.Transpose(array); } else if (input.Equals("upper")) { SquareArray.UpperTriangle(array); } else if (input.Equals("lower")) { SquareArray.LowerTriangle(array); } Console.WriteLine(); } while (input.Equals("end") == false); Console.ReadKey(); }
public void ArrayAdditionWithDifferenceSizes_ShouldThrowException() { int[,] squareCollection = { {1,2,3,4,5}, {2,5,6,2,2}, {1,1,1,1,1}, {2,2,2,2,2}, {6,1,3,0,3} }; int[,] diagCollection = { }; SquareArray<int> array1 = new SquareArray<int>(squareCollection); SquareArray<int> array2 = new SquareArray<int>(diagCollection); SquareArray<int> resultArray = ExtensionMethods.ArrayAddition(array1, array2); }
public TonItemBlock(SquareArray style, int blockId = -1) : base(style, blockId) { }
public InverseGunItemBlock(SquareArray style, int blockId = -1) : base(style, blockId) { }
protected ItemBlock(SquareArray style, int blockId = -1) : base(style, blockId) { Square.MarkMulti(this); }
static void Main(string[] args) { var sumList = PairSum.FindAPairsSumThatMatchesTarget(new List <int>() { 1, 2, 3, 4, 6 }, 6); Console.WriteLine($"Sum List [{sumList[0]}, {sumList[1]}]"); Console.WriteLine(); var sumListAlt = PairSum.FindAPairsAltSolution(new List <int>() { 1, 2, 3, 4, 6 }, 6); Console.WriteLine($"Sum List Alt [{sumList[0]}, {sumList[1]}]"); Console.WriteLine(); var removeDups = RemoveDuplicates.RemoveAllDuplicateNumbers(new List <int>() { 2, 2, 2, 11 }); Console.WriteLine($"Length after Dups have been removed: {removeDups}"); Console.WriteLine(); var removeDupsEducativeVersion = RemoveDuplicates.RemoveAllDupsWithArray(new int[] { 2, 3, 3, 3, 6, 9, 9 }); Console.WriteLine($"Length after Dups have been removed: {removeDupsEducativeVersion}"); Console.WriteLine(); var easySquares = SquareArray.GenerateListOfSquaresEasy(new List <int>() { -2, -1, 0, 2, 3 }); Console.Write($"[ "); foreach (var number in easySquares) { Console.Write($"{number} "); } Console.Write($"]"); Console.WriteLine(); var squares = SquareArray.GenerateArrayOfSquares(new int[] { -2, -1, 0, 2, 3 }); Console.Write($"[ "); foreach (var number in squares) { Console.Write($"{number} "); } Console.Write($"]"); Console.WriteLine(); var listSquares = SquareArray.GenerateListOfSquares(new List <int>() { -2, -1, 0, 2, 3 }); Console.Write($"[ "); foreach (var number in listSquares) { Console.Write($"{number} "); } Console.Write($"]"); Console.WriteLine(); var triplets = TripletsToZero.FindUniqueTripletsThatEqualZero(new List <int>() { -3, 0, 1, 2, -1, 1, -2 }); foreach (var list in triplets) { Console.Write($"Triplet: "); foreach (var number in list) { Console.Write($"{number} "); } Console.WriteLine(); } Console.WriteLine(); var closestToTarget = TripletSum.FindTripletSumClosestToTarget(new List <int>() { 1, 0, 1, 1 }, 100); Console.WriteLine($"Closest: {closestToTarget}"); Console.WriteLine(); var searchTriplet = TripletSum.SearchTriplet(new int[] { 1, 0, 1, 1 }, 100); Console.WriteLine($"Educative Closest: {searchTriplet}"); Console.WriteLine(); var tripletCount = CountTriplets.CountTripletsThatHasASumLessThanTarget(new List <int>() { -1, 4, 2, 1, 3 }, 5); Console.WriteLine($"Triplets Less than target: {tripletCount}"); Console.WriteLine(); var productsList = ProductLessThanTarget.FindProductsLessThanTarget(new List <int>() { 8, 2, 6, 5 }, 50); Console.WriteLine($"Product List: "); foreach (var list in productsList) { Console.Write(" ["); foreach (var number in list) { Console.Write($"{number} "); } Console.Write("] "); } Console.WriteLine(); var productsEducative = ProductLessThanTarget.FindProductEducative(new int[] { 8, 2, 2, 5 }, 50); Console.WriteLine($"Product List: "); foreach (var list in productsEducative) { Console.Write(" ["); foreach (var number in list) { Console.Write($"{number} "); } Console.Write("] "); } Console.WriteLine(); var dutchFlag = DutchFlag.SortInPlace(new List <int>() { 2, 2, 0, 1, 2, 0 }); Console.WriteLine("DutchFlag = "); foreach (var number in dutchFlag) { Console.Write($"{number} "); } Console.WriteLine(); var quad = QaudSum.ListOfQuads(new List <int>() { 4, 1, 2, -1, 1, -3, 28, -26 }, 1); Console.WriteLine("Quad List: "); foreach (var list in quad) { Console.Write($"["); foreach (var number in list) { Console.Write($"{number} "); } Console.Write("]"); } Console.WriteLine(); }