Предмет: Информатика, автор: Аноним

C# Сделать в C#
Помогите сделать​

Приложения:

Sulik200000: Что в себе содержит массив авто? Структуры, массивы или что?
Sulik200000: Я сделаю функцию, которая будет принимать структуры авто

Ответы

Автор ответа: Sulik200000
1

Ответ:

struct Auto

{

   public string Name;

   public string Mark;

   public string Color;

   public int Cost;

}

class Programm

{

   static int Max(Auto[] args)

   {

       int cost = args[0].Cost;

       int index = 0;

       for(int j = 0; j < args.Length; j++)

       {

           if (args[j].Cost > cost)

           {

               cost = args[j].Cost;    

               index = j;

           }

       }

       return index;

   }

   public static void Answer(Auto[] args)

   {

       System.Console.Clear();

       int i = Max(args);

       System.Console.WriteLine($"{args[i].Name}, {args[i].Cost}, {args[i].Mark}, {args[i].Color}");

       string input = System.Console.ReadLine();

       foreach(Auto k in args)

       {

           if (k.Name == input)

           {

               System.Console.WriteLine($"{k.Name}, {k.Mark}, {k.Color}, {k.Cost}");

               return;

           }

       }

       System.Console.WriteLine("Wrong name!");

       Answer(args);

   }

}

Похожие вопросы