Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- using namespace std;
- void Pechat(int** mass, int n){
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cout << mass[i][j] << " ";
- }
- cout << endl;
- }
- }
- int* mass(int m,int d){
- int* mass = new int[m];
- for (int i = 0; i < m; i++){
- cout << "Введите элемент [" << d << "," << i << "] " << endl;
- cin >> mass[i];
- }
- return mass;
- }
- int** matr(int m){
- int i = 0;
- int** matr = new int*[m];
- while (i < m){
- matr[i] = mass(m,i);
- i++;
- }
- return matr;
- }
- void main(){
- int max, j, i, p,m;
- setlocale(LC_ALL, "rus");
- cout << "Введите размерность матрицы" << "\n";
- cin >> m;
- int** a = matr(m);
- Pechat(a, m);
- cout << endl;
- for (i = 0; i < m; i++){
- max = a[i][i];
- for (j = 0; j < m; j++)
- {
- if (max < a[i][j]) { max = a[i][j]; p = j; }
- }
- a[i][p] = a[i][i];
- a[i][i] = max;
- }
- cout << endl;
- cout << "Матрица после обработки :" << endl;
- cout << endl;
- Pechat(a, m);
- }
Advertisement
Add Comment
Please, Sign In to add comment