Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "");
- int m, n, i, j, a;
- float max = 0, min = 0, pom = 0;
- float A[10][10];
- int maxi = 0, maxj = 0, mini = 0, minj = 0;
- cout << "Podaj ilość wierszy: ";
- cin >> m;
- cout << "Podaj ilość kolumn: ";
- cin >> n;
- cout << ">> Podaj elementy macierzy << " << endl;
- for (i = 0; i < m; i++)
- {
- for (j = 0; j < n; j++)
- {
- cout << "A[" << i + 1 << "][" << j + 1 << "]: ";
- cin >> A[i][j];
- }
- }
- cout << ">> Macierz A <<" << endl;
- for (i = 0; i < m; i++)
- {
- for (j = 0; j < n; j++)
- {
- cout << fixed << setprecision(2) << setw(7) << A[i][j];
- }
- cout << "\n";
- }
- cout << "Podaj numer wiersza: ";
- cin >> a;
- max = A[a - 1][0];
- min = A[a - 1][0];
- for (j = 0; j < n; j++)
- {
- if (A[a - 1][j] > max)
- {
- max = A[a - 1][j];
- maxj = j;
- }
- if (A[a - 1][j] < min)
- {
- min = A[a - 1][j];
- minj = j;
- }
- }
- cout << "Wartość maksymalna w wierszu " << a << ": " << max << endl;
- cout << "Wartość minimalna w wierszu " << a << ": " << min << endl;
- pom = A[a-1][maxj];
- A[a-1][maxj] = A[a-1][minj];
- A[a-1][minj] = pom;
- cout << ">> Macierz A po zamianie <<" << endl;
- for (i = 0; i < m; i++)
- {
- for (j = 0; j < n; j++)
- {
- cout << fixed << setprecision(2) << setw(7) << A[i][j];
- }
- cout << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement