Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using CoolerLibrary;
- namespace Lab10
- {
- class Program
- {
- public static void Continue()
- {
- Console.WriteLine("Нажмите любую клавишу для продолжения");
- Console.ReadKey();
- Console.Clear();
- }
- public static int FindMin(TriangleList triangleList)
- {
- int index = -1;
- double min = double.MaxValue;
- for(int i=0;i<triangleList.Size;i++)
- {
- if((triangleList[i].Square() !=-1) && (triangleList[i].Square()<min))
- {
- min = triangleList[i].Square();
- index = i;
- }
- }
- return index;
- }
- public static void Main()
- {
- TriangleList triangleList=new TriangleList();
- string[] Creation = { "Создание массива случайновй длинны со случайными элементами",
- "Cоздание массива заданной длинны со случайными элементами",
- "Создание массива заданной длинны с заданными элементами" };
- switch(Menu.menu(Creation))
- {
- case 1:
- triangleList = new TriangleList(true);
- break;
- case 2:
- int b = 0;
- Random rnd = new Random();
- Console.WriteLine("Введите размер");
- Reader.ReadPol(ref b);
- triangleList = new TriangleList(b, rnd);
- break;
- case 3:
- int a = 0;
- Console.WriteLine("Введите размер");
- Reader.ReadPol(ref a);
- triangleList = new TriangleList(a);
- break;
- }
- triangleList.Show();
- Continue();
- string[] actions = {"Печать","Обращение по индексу к элементу", "Увеличить элемент", "Уменьшить элемент ", ">","<","Минимальная площадь","Размер массива","Выход"};
- bool isContinue = true;
- while (isContinue)
- {
- int range = actions.Length;
- int vibor = Menu.menu(actions);
- switch (vibor)
- {
- case 1:
- triangleList.Show();
- Continue();
- break;
- case 2:
- int index = 0;
- Console.WriteLine("Введите индекс для обращения в размере от 0 до " + (triangleList.Size-1));
- Reader.ReadPol(ref index);
- Console.WriteLine(triangleList[index].ToString());
- Continue();
- break;
- case 3:
- int index1 = 0;
- Console.WriteLine("Введите индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
- Reader.ReadPol(ref index1);
- Console.WriteLine("Cтандартное значение ");
- Console.WriteLine(triangleList[index1].ToString());
- Console.WriteLine("Увеличенное значение");
- Console.WriteLine(triangleList[index1]++.ToString());
- Continue();
- break;
- case 4:
- int index2 = 0;
- Console.WriteLine("Введите индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
- Reader.ReadPol(ref index2);
- Console.WriteLine("Cтандартное значение ");
- Console.WriteLine(triangleList[index2].ToString());
- Console.WriteLine("Уменьшенное значение");
- Console.WriteLine(triangleList[index2]--.ToString());
- Continue();
- break;
- case 5:
- int index5_1 = 0;
- int index5_2 = 0;
- Console.WriteLine("Введите 1ый индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
- Reader.ReadPol(ref index5_1);
- Console.WriteLine("Sqare1="+"{0:0.##}", triangleList[index5_1].Square());
- Console.WriteLine("Введите 2ой индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
- Reader.ReadPol(ref index5_2);
- Console.WriteLine("Sqare2=" + "{0:0.##}", triangleList[index5_2].Square());
- Console.WriteLine("Square1 > Square2");
- Console.WriteLine("Результат= "+ (triangleList[index5_1] > triangleList[index5_2]));
- Continue();
- break;
- case 6:
- int index6_1 = 0;
- int index6_2 = 0;
- Console.WriteLine("Введите 1ый индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
- Reader.ReadPol(ref index6_1);
- Console.WriteLine("Sqare1=" + "{0:0.##}", triangleList[index6_1].Square());
- Console.WriteLine("Введите 2ой индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
- Reader.ReadPol(ref index6_2);
- Console.WriteLine("Sqare2=" + "{0:0.##}", triangleList[index6_2].Square());
- Console.WriteLine("Square1 < Square2");
- Console.WriteLine("Результат= " + (triangleList[index6_1] < triangleList[index6_2]));
- Continue();
- break;
- case 7:
- int id = FindMin(triangleList);
- if(id!=-1)
- {
- Console.WriteLine("Min SquareIndex= " + id);
- Console.WriteLine("Min square= {0:0.##}", triangleList[id].Square());
- Console.WriteLine("Min Triangle = " + triangleList[id].ToString());
- }
- else
- {
- Console.WriteLine("Нет площадей");
- }
- Continue();
- break;
- case 8:
- Console.WriteLine("Razmer_size= "+triangleList.Size+ " Razemer_count= " + Triangle.Count);
- Continue();
- break;
- }
- if(vibor==range)
- {
- isContinue = false;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement