Geradot345

lb6.2(

Oct 28th, 2020
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. //Щеглов В.А. 19ВИ1
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. void pol_stolb(int& n,int m,int** a){
  8. int i,j,p_stolb=-1,b=0;
  9. for(j=0;j<n;j++){
  10. for(i=0;i<m;i++){
  11. if(a[i][j]>0) b++;
  12. }
  13. if(b==m) {p_stolb=j;
  14. break;}
  15. b=0;
  16. }
  17. if (!(p_stolb==-1)){
  18. n--;
  19. for(i=0;i<m;i++){
  20. for(j=p_stolb;j<n;j++){
  21. a[i][j]=a[i][j+1];
  22. }
  23. }
  24. int** c=new int*[m];
  25. for(i=0;i<m;i++){
  26. c[i]=new int[n+1];
  27. }
  28. c=a;
  29. int** a=new int*[m];
  30. for(i=0;i<m;i++){
  31. a[i]=new int[n];
  32. }
  33. for(i=0;i<m;i++){
  34. for(j=0;j<n;j++){
  35. a[i][j]=c[i][j];
  36. }
  37. }
  38. }
  39. }
  40.  
  41. int main()
  42. {
  43. setlocale(LC_ALL, "Russian");
  44. int i,n,m,b,j;
  45. b=0;
  46. cout<<"Введите кол-во строк в матрице: ";
  47. cin>>m;
  48. cout<<"Введите кол-во столбцов в матрице: ";
  49. cin>>n;
  50. int** a=new int*[m];
  51. for(i=0;i<m;i++){
  52. a[i]=new int[n];
  53. }
  54. cout<<"Все элементы матрицы:\n";
  55. for(i=0;i<=m-1;i++){
  56. for(j=0;j<n;j++){
  57. a[i][j]=rand()%10000 -5000;
  58. cout<<setw(6)<<a[i][j];
  59. }
  60. cout<<endl;
  61. }
  62. pol_stolb(n,m,a);
  63. cout<<"Получившаяся матрица: \n";
  64. for(i=0;i<m;i++){
  65. for(j=0;j<n;j++){
  66. cout<<setw(6)<<a[i][j];
  67. }
  68. cout<<endl;
  69. }
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment