В общем проблема такая, написал код который рандомизирует цифры и выводит их в двух мерный массив, массив содержит строки и столбцы, которые в водиться самим пользователем, и после выводиться, нужно к этому всему, сделать вывод ещё 2 строк, положительной строки и отрицательной, что бы в положительной строке, все цифры находились положительные а в отрицательной строке, отрицательные цифры, не могу допереть как это все расписать на c++ Ниже прелагаю готовый код, который нужен для основы, который рандомизирует числа и выводит их в строки и в столбцы Благодарю за внимания, буду ждать ответа, заранее спасибо, надеюсь на помощь <3 #include <iostream> #include <ctime> #include <iomanip> using namespace std; int main() { int r, c; int arr[100][100]; cout << "ROWS"; cin >> r; cout << "COLS"; cin >> c; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { arr[i][j] = rand() % 100 - 100; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cout << arr[i][j] << "\t"; } cout << endl; } return 0; } Код #include <iostream> #include <ctime> #include <iomanip> using namespace std; int main() { int r, c; int arr[100][100]; cout << "ROWS"; cin >> r; cout << "COLS"; cin >> c; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { arr[i][j] = rand() % 100 - 100; } } for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { cout << arr[i][j] << "\t"; } cout << endl; } return 0; }
#include <iostream> #include <time.h> using namespace std; int main() { int m, n, **mas; srand(time(0)); system("chcp 1251"); system("cls"); cout << "Строки: "; cin >> m; cout << "Столбцы: "; cin >> n; cout << "\nВывод массива: \n"; mas = new int*[m]; for (int i = 0; i < m; i++) { mas[i] = new int[n]; for (int j = 0; j < n; j++) { mas[i][j] = rand() % 201 - 100; cout << mas[i][j] << " "; } cout << "\n"; } cout << "\nПоложительные элементы: \n"; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (mas[i][j] > 0) cout << mas[i][j] << " "; cout << "\n\nОтрицательные элементы: \n"; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (mas[i][j] < 0) cout << mas[i][j] << " "; cout << "\n\n"; for (int i = 0; i < m; i++) delete[] mas[i]; delete[] mas; system("pause"); return 0; } C #include <iostream> #include <time.h> using namespace std; int main() { int m, n, **mas; srand(time(0)); system("chcp 1251"); system("cls"); cout << "Строки: "; cin >> m; cout << "Столбцы: "; cin >> n; cout << "\nВывод массива: \n"; mas = new int*[m]; for (int i = 0; i < m; i++) { mas[i] = new int[n]; for (int j = 0; j < n; j++) { mas[i][j] = rand() % 201 - 100; cout << mas[i][j] << " "; } cout << "\n"; } cout << "\nПоложительные элементы: \n"; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (mas[i][j] > 0) cout << mas[i][j] << " "; cout << "\n\nОтрицательные элементы: \n"; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (mas[i][j] < 0) cout << mas[i][j] << " "; cout << "\n\n"; for (int i = 0; i < m; i++) delete[] mas[i]; delete[] mas; system("pause"); return 0; }