Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int **creat(int &n, int &m)
- {
- cout << "n="; cin >> n; cout << "m="; cin >> m;
- int **mas = new int*[n];
- for (int i = 0; i < n; ++i)
- mas[i] = new int[m];
- for (int i = 0; i < n; ++i)
- for (int j = 0; j < m; ++j)
- {
- cout << "mas[" << i << "][" << j << "]="; cin >> mas[i][j];
- }
- return mas;
- }
- int main()
- {
- int n, m,maxj;
- cout << "n="; cin >> n; cout << "m="; cin >> m;
- int **a = creat(n, m);int max;
- for (int i = 0; i < n; ++i)
- {max=a[i][0];
- maxj =0;
- for (int j = 0; j < m; ++j)
- if (a[i][j]>max)
- {
- max = a[i][j];
- maxj=j;
- }
- a[i][maxj]*=-1;
- }
- cout<<"Полученная матрица:";
- for(int i=0;i<n;i++)
- {
- for(int j=0;j<n;j++)
- cout<<a[i][j]<<" ";
- cout<<endl;
- }
- for (int i = 0; i < n; ++i)
- delete[]a[i];
- delete[]a;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment