Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <conio.h>
- using namespace std;
- int mat[10][10], n, m;
- void Citire(int n, int m, int mat[10][10]) {
- for(int i = 1; i <= n; i++) {
- for(int j = 1; j <= m; j++) {
- cout << "mat[" << i << "][" << j << "] = ";
- cin >> mat[i][j];
- }
- }
- }
- void Afisare() {
- for(int i = 1; i <= n; i++) {
- for(int j = 1; j <= m; j++) {
- cout << mat[i][j] << " ";
- }
- cout << endl;
- }
- }
- int Nmaxim, Mmaxim, Nminim, mMinim;
- int maxim(int n, int m, int mat[10][10]) {
- int max = mat[1][1];
- for(int i = 1; i <= n; i++)
- for(int j = 1; j <= m; j++)
- if(mat[i][j] > max) {
- max = mat[i][j];
- Nmaxim = i;
- Mmaxim = j;
- }
- return max;
- }
- int minim(int n, int m, int mat[10][10]) {
- int min = mat[1][1];
- for(int i = 1; i <= n; i++)
- for(int j = 1; j <= m; j++)
- if(mat[i][j] < min) {
- min = mat[i][j];
- Nminim = i;
- mMinim = j;
- }
- return min;
- }
- int main() {
- cin >> n >> m;
- Citire(n, m, mat);
- Afisare();
- cout << "\n\n";
- int M, MIN;
- M = maxim(n, m, mat);
- MIN = minim(n, m, mat);
- mat[Nmaxim][Mmaxim] = MIN;
- mat[Nminim][mMinim] = M;
- Afisare();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment