Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- #include <iostream>
- #include <ctime>
- #include <conio.h>
- #include <math.h>
- #include <stdio.h>
- #include <conio.h>
- #include <Windows.h>
- using namespace std;
- const int n = 10;
- const int m = 10;
- void Replace(int **Matrix, int n, int m)
- {
- int Max;
- for (int i = 0; i < n; i++)
- {
- Max = 0;
- for (int j = 0; j < m; j++)
- {
- if (Matrix[i][Max] < Matrix[i][j]) Max = j;
- }
- if (Max != i)
- {
- int temp = Matrix[i][Max];
- Matrix[i][Max] = Matrix[i][i];
- Matrix[i][i] = temp;
- }
- }
- }
- void inPut(int **Matrix,int n,int m)
- {
- for (int i = 0; i < n;i++)
- {
- for (int j = 0; j < m; j++)
- {
- Matrix[i][j] = rand() % 10;
- }
- }
- }
- void outPut(int **Matrix, int n, int m)
- {
- cout << "Матрица" << endl;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- cout << Matrix[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int n, m;
- cout << "Введите число n: ";
- cin >> n;
- cout << "Введите число m: ";
- cin >> m;
- int **Mat;
- Mat = new int*[n];
- for (int j = 0; j < m; j++) Mat[j] = new int[m];
- inPut(Mat, n, m);
- outPut(Mat, n, m);
- Replace(Mat, n, m);
- outPut(Mat, n, m);
- system("pause");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement