Advertisement
kirya522

Untitled

Feb 24th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.56 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using CoolerLibrary;
  4.  
  5. namespace Lab10
  6. {
  7.     class Program
  8.     {
  9.         public static void Continue()
  10.         {
  11.             Console.WriteLine("Нажмите любую клавишу для продолжения");
  12.             Console.ReadKey();
  13.             Console.Clear();
  14.         }
  15.         public static int FindMin(TriangleList triangleList)
  16.         {
  17.             int index = -1;
  18.             double min = double.MaxValue;
  19.             for(int i=0;i<triangleList.Size;i++)
  20.             {
  21.                 if((triangleList[i].Square() !=-1) && (triangleList[i].Square()<min))
  22.                     {
  23.                     min = triangleList[i].Square();
  24.                     index = i;
  25.                     }
  26.             }
  27.             return index;
  28.         }
  29.         public static void Main()
  30.         {
  31.             TriangleList triangleList=new TriangleList();
  32.             string[] Creation = { "Создание массива случайновй длинны со случайными элементами",
  33.                                   "Cоздание массива заданной длинны со случайными элементами",
  34.                                   "Создание массива заданной длинны с заданными элементами"  };
  35.             switch(Menu.menu(Creation))
  36.             {
  37.                 case 1:
  38.                     triangleList = new TriangleList(true);
  39.                     break;
  40.                 case 2:
  41.                     int b = 0;
  42.                     Random rnd = new Random();
  43.                     Console.WriteLine("Введите размер");
  44.                     Reader.ReadPol(ref b);
  45.                     triangleList = new TriangleList(b, rnd);
  46.                     break;
  47.                 case 3:
  48.                     int a = 0;
  49.                     Console.WriteLine("Введите размер");
  50.                     Reader.ReadPol(ref a);
  51.                     triangleList = new TriangleList(a);
  52.                     break;
  53.             }
  54.             triangleList.Show();
  55.             Continue();
  56.  
  57.             string[] actions = {"Печать","Обращение по индексу к элементу", "Увеличить элемент", "Уменьшить элемент ", ">","<","Минимальная площадь","Размер массива","Выход"};
  58.             bool isContinue = true;
  59.             while (isContinue)
  60.             {
  61.                 int range = actions.Length;
  62.                 int vibor = Menu.menu(actions);
  63.                 switch (vibor)
  64.                 {
  65.                     case 1:
  66.                         triangleList.Show();
  67.                         Continue();
  68.                         break;
  69.                     case 2:
  70.                         int index = 0;
  71.                         Console.WriteLine("Введите индекс для обращения в размере от 0 до " + (triangleList.Size-1));
  72.                         Reader.ReadPol(ref index);
  73.                         Console.WriteLine(triangleList[index].ToString());
  74.                         Continue();
  75.                         break;
  76.                     case 3:
  77.                         int index1 = 0;
  78.                         Console.WriteLine("Введите индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
  79.                         Reader.ReadPol(ref index1);
  80.                         Console.WriteLine("Cтандартное значение ");
  81.                         Console.WriteLine(triangleList[index1].ToString());
  82.                         Console.WriteLine("Увеличенное значение");
  83.                         Console.WriteLine(triangleList[index1]++.ToString());
  84.                         Continue();
  85.                         break;
  86.                     case 4:
  87.                         int index2 = 0;
  88.                         Console.WriteLine("Введите индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
  89.                         Reader.ReadPol(ref index2);
  90.                         Console.WriteLine("Cтандартное значение ");
  91.                         Console.WriteLine(triangleList[index2].ToString());
  92.                         Console.WriteLine("Уменьшенное значение");
  93.                         Console.WriteLine(triangleList[index2]--.ToString());
  94.                         Continue();
  95.                         break;
  96.                     case 5:
  97.                         int index5_1 = 0;
  98.                         int index5_2 = 0;
  99.                         Console.WriteLine("Введите 1ый индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
  100.                         Reader.ReadPol(ref index5_1);
  101.                         Console.WriteLine("Sqare1="+"{0:0.##}", triangleList[index5_1].Square());
  102.                         Console.WriteLine("Введите 2ой индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
  103.                         Reader.ReadPol(ref index5_2);
  104.                         Console.WriteLine("Sqare2=" + "{0:0.##}", triangleList[index5_2].Square());
  105.                         Console.WriteLine("Square1 > Square2");
  106.                         Console.WriteLine("Результат= "+ (triangleList[index5_1] > triangleList[index5_2]));
  107.                         Continue();
  108.                         break;
  109.                     case 6:
  110.                         int index6_1 = 0;
  111.                         int index6_2 = 0;
  112.                         Console.WriteLine("Введите 1ый индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
  113.                         Reader.ReadPol(ref index6_1);
  114.                         Console.WriteLine("Sqare1=" + "{0:0.##}", triangleList[index6_1].Square());
  115.                         Console.WriteLine("Введите 2ой индекс для обращения в размере от 0 до " + (triangleList.Size - 1));
  116.                         Reader.ReadPol(ref index6_2);
  117.                         Console.WriteLine("Sqare2=" + "{0:0.##}", triangleList[index6_2].Square());
  118.                         Console.WriteLine("Square1 < Square2");
  119.                         Console.WriteLine("Результат= " + (triangleList[index6_1] < triangleList[index6_2]));
  120.                         Continue();
  121.                         break;
  122.                     case 7:
  123.                         int id = FindMin(triangleList);
  124.                        
  125.                        
  126.                         if(id!=-1)
  127.                         {
  128.                             Console.WriteLine("Min SquareIndex=  " + id);
  129.                             Console.WriteLine("Min square= {0:0.##}", triangleList[id].Square());
  130.                             Console.WriteLine("Min Triangle = " + triangleList[id].ToString());
  131.                         }
  132.                         else
  133.                         {
  134.                             Console.WriteLine("Нет площадей");
  135.                         }
  136.                         Continue();
  137.                         break;
  138.                     case 8:
  139.                         Console.WriteLine("Razmer_size= "+triangleList.Size+ " Razemer_count= " + Triangle.Count);
  140.                         Continue();
  141.                         break;
  142.                 }
  143.                 if(vibor==range)
  144.                 {
  145.                     isContinue = false;
  146.                 }
  147.  
  148.             }
  149.         }
  150.     }
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement