Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdlib.h>
- #include<time.h>
- #include<Windows.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);//русский
- srand(time(NULL));
- int n, m, x;
- cout << "Введите количество строк" << "\n";
- cin >> n;
- m = 2 * n; //столбцы
- cout << "Введите X" << "\n";
- cin >> x;
- // динамическое создание двумерного массива
- int** A = new int* [n]; // строк в массиве
- for (int i = 0; i < n; i++)
- A[i] = new int[m]; // столбцов
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- A[i][j] = rand() % 100;
- cout << setw(3) << A[i][j] << ' ';
- }
- cout << "\n";
- }
- // Массив b
- int* b= new int[n];
- for (int i = 0; i < n; i++)
- {
- if (A[i][0]<=x)
- b[i] = 1;
- else
- b[i] = 0;
- }
- for (int i = 0; i < n; i++)
- {
- cout << b[i] << " ";
- }
- // Удаление массива
- for (int i = 0; i < n; i++)
- {
- delete[]A[i];
- }
- delete[] A;
- delete[] b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment