Superymniaha
21.06.2021 16:03

Решите Информатика. Очень важное задание.. Заранее благодарю за

Нажмите на рекламу ниже и сразу увидите ответ
Популярные вопросы:
Ответ:
dauren130
24.11.2021 18:52

Объяснение:

#include <iostream>

#include <ctime>

#include <string>

using namespace std;

int main()

{

   srand(time(NULL));

   int N, M; // Розміри матриці

   cout << "Enter n: ";

   cin >> N;

   cout << "Enter m: ";

   cin >> M;

   if (N != M) // Перевірка на не квадратну матрицю

   {

       cout << "n should be equal to m" << endl;

       return 0;

   }

   int a, b; // Межі випадкових чисел масиву

   cout << "Enter a: ";

   cin >> a;

   cout << "Enter b: ";

   cin >> b;

   int Width = max(to_string(a).length(), to_string(b).length()) + 1; // Ширина для cout

   int** arr = new int* [N]; // Виділення пам'яті для динамічного масиву

   int** result = new int* [N]; // Виділення пам'яті для динамічного масиву (результат)

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

   {

       arr[i] = new int[M];

       result[i] = new int[M];

   }

   cout << "n = " << N << endl

       << "m = " << M << endl

       << "Interval - [" << a << ";" << b << "]" << endl << endl

       << "Our matrix: " << endl;

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

   {

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

       {

           arr[i][j] = a + rand() % (b - a + 1);

           cout.width(Width); // Щоб було красиво

           cout << arr[i][j];

       }

       cout << endl;

   }

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

   {

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

       {

           if (j == 0 && i != N - 1)

           {

               result[N - 1][i + 1] = arr[i][j];

           }

           else if (i == N - 1 && j != 0)

           {

               result[j - 1][0] = arr[i][j];

           }

           else

           {

               result[i][j] = arr[i][j];

           }

       }

   }

   cout << endl << "Result matrix:" << endl;

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

   {

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

       {

           cout.width(Width); // Щоб було красиво

           cout << result[i][j];

       }

       cout << endl;

   }

   for (int i = 0; i < N; i++) // Звільнення пам'яті відведеної під динамічні масиви

   {

       delete[] result[i];

       delete[] arr[i];

   }

   delete[] result;

   delete[] arr;

}

0,0(0 оценок)
Ответ:
vikaplmplmpl
13.10.2020 11:40
Program pretty;
var
  count, i, d1, d2, d3, d4, d5, d6: integer;
const
  MIN = 189980;
  MAX = 205505;
begin
  count := 0;
  for i := MIN to MAX do
    begin
      d1 := i div 100000;
      d2 := i mod 100000 div 10000;
      d3 := i mod 10000 div 1000;
      d4 := i mod 1000 div 100;
      d5 := i mod 100 div 10;
      d6 := i mod 10;
      if ( (d6 * 100000) + (d5 * 10000) + (d4 * 1000) + (d3 * 100) + (d2 * 10) + d1 ) = i
      then
        count := count + 1;
    end;
  writeln('в промежутке от ', MIN, ' до ', MAX, ' ', count, ' счастливых билетов');
end.
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота