示例#1
0
 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("Выберите массив с которым вы хотите работать, 1 или 2");
         Console.WriteLine("1: int[]");
         Console.WriteLine("2: string[]");
         int number = Convert.ToInt32(Console.ReadLine());
         if (number == 1)
         {
             Console.WriteLine(1);
         }
         while (number != 1 && number != 2)
         {
             Console.WriteLine("только 1 или 2");
             number = Convert.ToInt32(Console.ReadLine());
         }
         if (number == 1)
         {
             Console.WriteLine("Вы выбралт массив чисел\n");
             Console.WriteLine("Вы выбрали массив строк");
             int       arraySize = Convert.ToInt32(Console.ReadLine());
             ArrayWork arrayWork = new ArrayWork(arraySize);
             Console.WriteLine($"Размер массива {arraySize}\n");
             Console.WriteLine("Напишите индекс массива, чтобы увидеть элемент");
             int index = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine($"В индексе {index} размещено {arrayWork[index]}\n");
             Console.WriteLine("Если вы хотите изменить это значение, напишите новое значение, если не хотите напишите '0'");
             int newValue = Convert.ToInt32(Console.ReadLine());
             if (newValue != 0)
             {
                 arrayWork[index] = newValue;
                 Console.WriteLine($"Вы успешно изменили значение в индексе {index} на {arrayWork[index]}");
             }
         }
         else if (number == 2)
         {
             Console.WriteLine("Вы выбралт массив чисел\n");
             Console.WriteLine("Вы выбрали массив строк");
             int          arraySize = Convert.ToInt32(Console.ReadLine());
             ArrayWorkStr arrayWork = new ArrayWorkStr(arraySize);
             Console.WriteLine($"Размер массива {arraySize}\n");
             Console.WriteLine("Напишите индекс массива, чтобы увидеть элемент");
             int index = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine($"В индексе {index} размещено {arrayWork[index]}\n");
             Console.WriteLine("Если вы хотите изменить это значение, напишите новое значение, если не хотите напишите '0'");
             string newValue = Console.ReadLine();
             if (newValue != "0")
             {
                 arrayWork[index] = newValue;
                 Console.WriteLine($"Вы успешно изменили значение в индексе {index} on {arrayWork[index]}");
             }
         }
     }
     catch
     {
         Console.WriteLine("Значение должно быть числом");
     }
 }
示例#2
0
 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("Choose an array you want to work with, 1 or 2");
         Console.WriteLine("1: int[]");
         Console.WriteLine("2: string[]");
         int number = Convert.ToInt32(Console.ReadLine());
         if (number == 1)
         {
             Console.WriteLine(1);
         }
         while (number != 1 && number != 2)
         {
             Console.WriteLine("only 1 or 2");
             number = Convert.ToInt32(Console.ReadLine());
         }
         if (number == 1)
         {
             Console.WriteLine("You chose int array\n");
             Console.WriteLine("Write array size");
             int       arraySize = Convert.ToInt32(Console.ReadLine());
             ArrayWork arrayWork = new ArrayWork(arraySize);
             Console.WriteLine($"Size of the array is {arraySize}\n");
             Console.WriteLine("Write an index of the array to see an element");
             int index = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine($"In index {index} is {arrayWork[index]}\n");
             Console.WriteLine("If you want to change this value write new value, if don't want write '0'");
             int newValue = Convert.ToInt32(Console.ReadLine());
             if (newValue != 0)
             {
                 arrayWork[index] = newValue;
                 Console.WriteLine($"You successfully change the value in index {index} on {arrayWork[index]}");
             }
         }
         else if (number == 2)
         {
             Console.WriteLine("You chose string array\n");
             Console.WriteLine("Write array size");
             int          arraySize = Convert.ToInt32(Console.ReadLine());
             ArrayWorkStr arrayWork = new ArrayWorkStr(arraySize);
             Console.WriteLine($"Size of the array is {arraySize}\n");
             Console.WriteLine("Write an index of the array to see an element");
             int index = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine($"In index {index} is {arrayWork[index]}\n");
             Console.WriteLine("If you want to change this value write new value, if don't want write '0'");
             string newValue = Console.ReadLine();
             if (newValue != "0")
             {
                 arrayWork[index] = newValue;
                 Console.WriteLine($"You successfully change the value in index {index} on {arrayWork[index]}");
             }
         }
     }
     catch
     {
         Console.WriteLine("Must be an integer");
     }
 }
示例#3
0
        private void maxButton_Click(object sender, EventArgs e)
        {
            double[] values    = GetValues(AnDGV);
            double[] localMaxs = ArrayWork.GetLocalMaxs(values);
            if (localMaxs.Length == 0)
            {
                resultLabel.Text = "Результат: Локальных максимумов нет";
                return;
            }
            double max = ArrayWork.GetMinFromMaxs(localMaxs);

            resultLabel.Text = "Результат: " + max;
        }