Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int matrix[5][5], tmp_mas[5];
- void bubble_sort() //глобальные переменные: mas -- сам массив, mas_size -- размер массива mas
- {
- for (int i = 0; i<5; ++i)
- for (int j = i + 1; j<5; ++j)
- if (tmp_mas[j]<tmp_mas[i])swap(tmp_mas[i], tmp_mas[j]);
- }
- void matrix_input()
- {
- int i = 0, j = 0;
- cout << "Введите матрицу 5x5:\n";
- while (i < 5)
- {
- while (j < 5)
- {
- cin >> matrix[i][j];
- j++;
- }
- j = 0;
- i++;
- }
- }
- void matrix_output()
- {
- cout << "=-=-=-=-=-=-=-=-=-=-=-\n";
- int i = 0, j = 0;
- while (i < 5)
- {
- while (j < 5)
- {
- cout << matrix[i][j] << ' ';
- j++;
- }
- cout << endl;
- j = 0;
- i++;
- }
- cout << "=-=-=-=-=-=-=-=-=-=-=-\n";
- }
- int main()
- {
- int i = 0, j = 0;
- setlocale(LC_ALL, "russian");
- system("color 0A");
- matrix_input();
- matrix_output();
- while (i < 5)
- {
- while (j < 5)
- {
- tmp_mas[i] = matrix[i][j];
- bubble_sort();
- matrix[i][j] = tmp_mas[i];
- j++;
- }
- j = 0;
- i++;
- }
- matrix_output();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment