Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Щеглов В.А. 19ВИ1
- #include <iostream>
- #include <iomanip>
- using namespace std;
- void pol_stolb(int& n,int m,int** a){
- int i,j,p_stolb=-1,b=0;
- for(j=0;j<n;j++){
- for(i=0;i<m;i++){
- if(a[i][j]>0) b++;
- }
- if(b==m) {p_stolb=j;
- break;}
- b=0;
- }
- if (!(p_stolb==-1)){
- n--;
- for(i=0;i<m;i++){
- for(j=p_stolb;j<n;j++){
- a[i][j]=a[i][j+1];
- }
- }
- int** c=new int*[m];
- for(i=0;i<m;i++){
- c[i]=new int[n+1];
- }
- c=a;
- int** a=new int*[m];
- for(i=0;i<m;i++){
- a[i]=new int[n];
- }
- for(i=0;i<m;i++){
- for(j=0;j<n;j++){
- a[i][j]=c[i][j];
- }
- }
- }
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int i,n,m,b,j;
- b=0;
- cout<<"Введите кол-во строк в матрице: ";
- cin>>m;
- cout<<"Введите кол-во столбцов в матрице: ";
- cin>>n;
- int** a=new int*[m];
- for(i=0;i<m;i++){
- a[i]=new int[n];
- }
- cout<<"Все элементы матрицы:\n";
- for(i=0;i<=m-1;i++){
- for(j=0;j<n;j++){
- a[i][j]=rand()%10000 -5000;
- cout<<setw(6)<<a[i][j];
- }
- cout<<endl;
- }
- pol_stolb(n,m,a);
- cout<<"Получившаяся матрица: \n";
- for(i=0;i<m;i++){
- for(j=0;j<n;j++){
- cout<<setw(6)<<a[i][j];
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment