Beispiel #1
0
    public static void Main()
    {
        int size = 20, multiplier = 5;

        var intArray = ArrayElementsAsIndexMultipliedBy(size, multiplier);

        // for this homework I decided to try out a static class, so you will find the logic
        // for ArrayTo.String in the ArrayTools.cs file in the solution
        // which I created to collect functionality that I used in more than one project
        // and just added a link to each project I need it into
        // this way each project is more clear, and I can use same functionality without duplicating code
        Console.WriteLine(ArrayTo.String(intArray));
    }
Beispiel #2
0
    static void PrintOutput()
    {
        int[] startArray = (int[])arr.Clone();
        Sort.Selection(arr);
        int[] binarySearchResult = Search.Binary(numToFind, arr);

        int foundAtIndex = binarySearchResult [0];
        int operations   = binarySearchResult [1];

        Console.WriteLine("Start array:  " + ArrayTo.String(startArray));
        Console.WriteLine("Sorted array: " + ArrayTo.String(arr));
        if (binarySearchResult [0] == -1)
        {
            Console.WriteLine("Not Found");
            return;
        }
        Console.WriteLine("Found " + numToFind + " at index " + foundAtIndex + " with " + operations + (operations == 1 ? " operation." : " operations."));
    }
Beispiel #3
0
 static void PrintOutput()
 {
     Sort.Selection(arr);
     Console.WriteLine(ArrayTo.String(arr));
 }
Beispiel #4
0
 static void PrintResult()
 {
     Console.WriteLine("\n" + ArrayTo.String((FindArraySequence.Equals(arr))));
 }
Beispiel #5
0
 static void PrintOutput()
 {
     Console.WriteLine(ArrayTo.String(MaxKSumInArray(array)));
 }
Beispiel #6
0
 static void PrintResult()
 {
     Console.WriteLine("\n" + ArrayTo.String(FindArraySequence.Increasing(arr)));
 }
Beispiel #7
0
 public static void Main()
 {
     Sort.Quick(arr, 0, arr.Length - 1);
     Console.WriteLine(ArrayTo.String(arr));
 }
Beispiel #8
0
 static void PrintOutput()
 {
     Console.WriteLine(ArrayTo.String(FindArraySequence.Sum(11, arr)));
 }
Beispiel #9
0
 static void PrintOutput()
 {
     int[] maxSumSequence = FindArraySequence.MaxSum(arr);
     Console.WriteLine("Sequence: " + ArrayTo.String(maxSumSequence));
     Console.WriteLine("Sum: " + ValueFromArray.SumOfArray(maxSumSequence));
 }