Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Лекция по "Программированию"

Автор:   •  Октябрь 11, 2022  •  Лекция  •  3,997 Слов (16 Страниц)  •  142 Просмотры

Страница 1 из 16

ВтиПО 13   Сагындык Айдын

[pic 1]

8.1

[pic 2]

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace _8._1

{

    internal class Program

    {

        static void Main(string[] args)

        {

            int[,] matrix = new int[5, 5];

            Random Rand = new Random();

            int M = int.Parse(Console.ReadLine());

            Console.WriteLine();

            int summa = 0;

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

            {

                for (int j = 0; j < 5; j++)

                {

                    matrix[i, j] = Rand.Next(-50, 50);

                    Console.Write(matrix[i,j] + "\t");

                    if (i + j == M)

                    {

                        summa += matrix[i, j];

                    }

                }

                Console.WriteLine();

            }

            Console.WriteLine();

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

            {

                for (int j = 0; j < 5; j++)

                {

                    if (i + j == M)

                    {

                        Console.Write($" ({i},{j}) {matrix[i, j]} + ");

                    }

                }  

            }

            Console.WriteLine(" = " +summa);

        }

    }

}

8.2

[pic 3]

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace _8._2

{

    internal class Program

    {

        static void Main(string[] args)

        {

            int[,] matrix = new int[5, 5];

            Random Rand = new Random();

            int[] stroka = new int[5];

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

            {

                for (int j = 0; j < 5; j++)

                {

                    matrix[i, j] = Rand.Next(-50, 50);

                    if (j == 4)

                    {

                        Console.Write($"({matrix[i, j]})");

                    }

                    else

                    {

                        Console.Write($"({matrix[i, j]}) +");

                    }

                    stroka[i] += matrix[i, j];

                }

                Console.Write(" = " + stroka[i] + "\n");

            }

            Console.WriteLine();

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

            {

                Console.Write(stroka[i] + "\t");

            }

        }

    }

}

8.3

[pic 4]

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace _8._3

{

    internal class Program

    {

        static void Main(string[] args)

...

Скачать:   txt (8.9 Kb)   pdf (739.7 Kb)   docx (756.5 Kb)  
Продолжить читать еще 15 страниц(ы) »
Доступно только на Essays.club