Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <clocale>
- #include <iomanip>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "rus");
- cout << "Введите кол-во строк и столбцов матрицы: ";
- int n, m,i,p=0;
- cin >> n >> m;
- cout << endl;
- int** a = new int *[n];
- for (int i = 0; i < n; ++i)
- a[i] = new int[m];
- cout << "Введите элементы матрицы:" << endl;
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cin >> a[i][j];
- }
- }
- cout << endl;
- for (int j = 0; j < m; j++){
- i = 0;
- while ((i < n) && (a[i][j]>0))
- i++;
- if (i < n){
- for (i = 0; i < n; i++)
- a[i][p] = a[i][j];
- p++;
- }
- }
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < p; j++) {
- cout << setw(3)<< a[i][j] << " ";
- }
- cout << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement