galereyaas1568
?>

30 найти значение переменной s при n=5, i=0 for i: =1 to n do begin a(i): =i; s: =s+a(i) end

Информатика

Ответы

kattarina71
S=1+2+3+4+5=15
syana80
В условии, скорее всего, вместо i=0 должно быть S=0.
i = 1: A(1) = 1, S = S+A(i) = 0+1 = 1
i = 2: A(2) = 2, S = 1+2 = 3
I = 3: A(3) = 3, S = 3+3 = 6
i = 4: A(4) = 4, S = 6+4 = 10
i = 5: A(5) = 5, S = 10+5 = 15
narkimry134

1)

using System;

using System.Collections.Generic;

using System.Collections.Specialized;

namespace ConsoleApp3

{

   class Program

   {

       static void Main(string[] args)

       {

           int num = Convert.ToInt32(Console.ReadLine());

           Console.WriteLine(num % 2 == 0 ? "Чётное" : "Нечётное");

           Console.WriteLine(num / 10 + num % 10);

       }

   }

}

2)

using System;

using System.Collections.Generic;

using System.Collections.Specialized;

namespace ConsoleApp3

{

   class Program

   {

       static void Main(string[] args)

       {

           double[] seconds = new double[8];

           string[] athletes = new string[8];

           double sum = 0;

           double maxN = 0;

           int max = 0;

           for (int i = 0; i < 8; i++)

           {

               Console.WriteLine($"Введите фамилию {i + 1}-го участника и его результат: ");

               athletes[i] = Console.ReadLine();

               seconds[i] = Convert.ToDouble(Console.ReadLine());

               sum += seconds[i];

               if (seconds[i] > maxN)

               {

                   maxN = seconds[i];

                   max = i;

               }

           }

           Console.WriteLine($"\n\nСредний результат участников - {sum / 8}");

           Console.WriteLine($"Лучший результат у участника с фамилией {athletes[max]} - {maxN}");

       }

   }

}

Васильев1028

1)

using System;

using System.Collections.Generic;

using System.Collections.Specialized;

namespace ConsoleApp3

{

   class Program

   {

       static void Main(string[] args)

       {

           int num = Convert.ToInt32(Console.ReadLine());

           Console.WriteLine(num % 2 == 0 ? "Чётное" : "Нечётное");

           Console.WriteLine(num / 10 + num % 10);

       }

   }

}

2)

using System;

using System.Collections.Generic;

using System.Collections.Specialized;

namespace ConsoleApp3

{

   class Program

   {

       static void Main(string[] args)

       {

           double[] seconds = new double[8];

           string[] athletes = new string[8];

           double sum = 0;

           double maxN = 0;

           int max = 0;

           for (int i = 0; i < 8; i++)

           {

               Console.WriteLine($"Введите фамилию {i + 1}-го участника и его результат: ");

               athletes[i] = Console.ReadLine();

               seconds[i] = Convert.ToDouble(Console.ReadLine());

               sum += seconds[i];

               if (seconds[i] > maxN)

               {

                   maxN = seconds[i];

                   max = i;

               }

           }

           Console.WriteLine($"\n\nСредний результат участников - {sum / 8}");

           Console.WriteLine($"Лучший результат у участника с фамилией {athletes[max]} - {maxN}");

       }

   }

}

Ответить на вопрос

Поделитесь своими знаниями, ответьте на вопрос:

30 найти значение переменной s при n=5, i=0 for i: =1 to n do begin a(i): =i; s: =s+a(i) end
Ваше имя (никнейм)*
Email*
Комментарий*