Задача 11 Составить программу которая будет расставлять по в порядке возрастания три введённых числа и находить сумму их квадратов. Пример: вводят 8, 4, 6 вывод 4, 6, 8 16+36+64 =116​

Giga45 Giga45    3   06.02.2021 21:21    0

Ответы
artyomburyanov artyomburyanov  08.03.2021 21:28

C#

double a, b, c, s;

           ConsoleKeyInfo keyInfo;

           do

           {

               Console.Write("Введите первое число: ");

               a = Convert.ToInt32(Console.ReadLine());

               Console.Write("Введите второе число: ");

               b = Convert.ToInt32(Console.ReadLine());

               Console.Write("Введите третее число: ");

               c = Convert.ToInt32(Console.ReadLine());

               Console.WriteLine("");

               if (a < b && a < c)

               {

                   Console.WriteLine(a);

                   Console.WriteLine(Math.Min(b, c));

                   Console.WriteLine(Math.Max(b, c));

               }

               if (b < a && b < c)

               {

                   Console.WriteLine(b);

                   Console.WriteLine(Math.Min(a, c));

                   Console.WriteLine(Math.Max(a, c));

               }

               if (c < b && c < a)

               {

                   Console.WriteLine(c);

                   Console.WriteLine(Math.Min(a, b));

                   Console.WriteLine(Math.Max(a, b));

               }

               Console.WriteLine("");

               a = Math.Pow(a, 2);

               b = Math.Pow(b, 2);

               c = Math.Pow(c, 2);

               if (a < b && a < c)

               {                    

                   Console.WriteLine(a);

                   Console.WriteLine(Math.Min(b, c));

                   Console.WriteLine(Math.Max(b, c));

               }                  

               

               if (b < a && b < c)

               {            

                   Console.Write(b);

                   Console.WriteLine(Math.Min(a, c));

                   Console.WriteLine(Math.Max(a, c));

               }

               if (c < b && c < a)

               {                    

                   Console.Write(c);

                   Console.WriteLine(Math.Min(a, b));

                   Console.WriteLine(Math.Max(a, b));

                   

               }

               Console.WriteLine("");

               s = a + b + c;

               Console.WriteLine("" + s + "\n");

               Console.WriteLine("Если хотите повторить программу нажмите F");

               Console.WriteLine("Если хотите завершить программу нажмите любую другую кнопку\n");

               keyInfo = Console.ReadKey(true);

           }

           while (keyInfo.Key == ConsoleKey.F);

ПОКАЗАТЬ ОТВЕТЫ
Jina9845 Jina9845  08.03.2021 21:28

Python:

def sorting(*args):

   print(*sorted(args))

   sum = 0

   for i in args:

       sum += i * i

   print(sum)

sorting(8, 4, 6)

Объяснение:

ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика