Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- void Chislo(int** a, int N, int M);
- int main()
- {
- int N, M;
- int **a;
- cout << "Vvedite N, M: ";
- cin >> N >> M;
- a = new int *[N];
- for (int i = 0; i < N; i++)
- a[i] = new int[M];
- for (int i = 0; i < N; i++)
- for (int j = 0; j < M; j++) {
- cout << "\t a[" << i + 1 << "][" << j + 1 << "] = ";
- cin >> a[i][j];
- }
- Chislo(a, N, M);
- cout << "\n Matrix A:" << endl;
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++)
- cout << "\t" << a[i][j];
- cout << endl;
- }
- cout << endl;
- delete[]a;
- system("Pause");
- return 0;
- }
- void Chislo(int** a, int N, int M){
- int min = a[0][0], chis, chis_n, chis_m;
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++) {
- if (a[i][j] < min)
- {
- min = a[i][j];
- chis_n = i;
- chis_m = j;
- }
- }
- }
- chis = a[N- 1][M - 1];
- a[chis_n][chis_m] = chis;
- a[N - 1][M - 1] = min;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement