Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- const int m = 5, n = 5;
- int array[m][n];
- int sum = m * n;
- //const int *row = &m, *coll = &m;
- char XXX;
- void Rand_fill(int start, int finish /*const int x, const int y*/)
- {
- srand(time(NULL));
- //int array[x][y];
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- array[i][j] = rand() % (finish - start + 1) + start;
- }
- }
- }
- void sort_m(int matrix[m][n])
- {
- for (int ir = 0; ir < m; ir++)
- {
- for (int ic = 0; ic < m; ic++)
- {
- for (int jr = 0; jr < n; jr++)
- {
- for (int jc = 0; jc < n; jc++)
- {
- if (matrix[ir][jr] > matrix[ic][jc])
- {
- int temp = matrix[ir][jr];
- matrix[ir][jr] = matrix[ic][jc];
- matrix[ic][jc] = temp;
- }
- }
- }
- }
- }
- }
- void display_matrix(int matrix[m][n]) {
- for (int i = 0; i < m; i++)
- {
- for (int j = 0; j < n; j++)
- {
- cout << " " << matrix[i][j];
- }
- cout << endl;
- }
- }
- int main()
- {
- /*
- const int m = 50, n = 50;
- int array;
- int sum = m * n;
- int *row = &m, *coll = &m;
- char XXX;
- */
- // cout << "podaj rozmiary macierzy przez X" << endl;
- // cin >> row >> XXX >> coll;
- Rand_fill(NULL, sum);
- cout << endl;
- cout << "macierz randomowa \n\n";
- display_matrix(array);
- cout << endl;
- cout << "macierz odsortowana \n\n";
- sort_m(array);
- display_matrix(array);
- cout << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement