Advertisement
Courbe_Impliquee

Удаление столбца!

May 31st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <clocale>
  4. #include <iomanip>
  5. using namespace std;
  6. int main()
  7. {
  8. setlocale(LC_ALL, "rus");
  9. cout << "Введите кол-во строк и столбцов матрицы: ";
  10. int n, m,i,p=0;
  11. cin >> n >> m;
  12. cout << endl;
  13. int** a = new int *[n];
  14. for (int i = 0; i < n; ++i)
  15. a[i] = new int[m];
  16. cout << "Введите элементы матрицы:" << endl;
  17. for (int i = 0; i < n; i++) {
  18. for (int j = 0; j < m; j++) {
  19. cin >> a[i][j];
  20. }
  21. }
  22. cout << endl;
  23.  
  24. for (int j = 0; j < m; j++){
  25. i = 0;
  26. while ((i < n) && (a[i][j]>0))
  27. i++;
  28. if (i < n){
  29. for (i = 0; i < n; i++)
  30. a[i][p] = a[i][j];
  31. p++;
  32. }
  33. }
  34.  
  35. for (int i = 0; i < n; i++) {
  36. for (int j = 0; j < p; j++) {
  37. cout << setw(3)<< a[i][j] << " ";
  38. }
  39. cout << endl;
  40. }
  41. system("pause");
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement