Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void work(int **A, int a, int b);
- void main() {
- setlocale (LC_ALL, "Russian");
- int rowdim, coldim;
- cin >> rowdim >> coldim;
- int **matrix = new int *[rowdim];
- for (int i = 0; i < rowdim; i++) {
- matrix[i] = new int [coldim];
- }
- for (int i = 0; i < rowdim; i++) {
- for (int j = 0; j < coldim; j++) {
- matrix[i][j] = rand() % 10;
- }
- }
- for (int i = 0; i < rowdim; i++) {
- for (int j = 0; j < coldim; j++) {
- cout << matrix[i][j] << ' ';
- }
- cout << endl;
- }
- work(matrix, rowdim, coldim);
- delete []matrix;
- system("pause");
- }
- void work(int **A, int k, int l) {
- for (int i = 0; i < k; i++) {
- for (int j = 0; j < l; j++) {
- if (!(j % 2)) {
- cout << A[i][j] << ' ';
- }
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment