Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int **mas1, *mas2;
- size_t n, m;
- cout << "vvedite N:" << endl;
- cin >> n;
- cout << "vvedite M:" << endl;
- cin >> m;
- mas1 = new int*[n];
- for (size_t i = 0; i < n; ++i)
- mas1[i] = new int[m];
- mas2 = new int[n]();
- for (size_t i = 0; i < n; ++i) {
- cout << "Vvedite stroku[" << i + 1 << "] " << endl;
- for (size_t j = 0; j < m; ++j)
- cin >> mas1[i][j];
- }
- cout << endl;
- for (size_t i = 0; i < n; ++i)
- {
- for (size_t j = 0; j < m; ++j)
- cout << mas1[i][j] << " ";
- cout << endl;
- }
- for (size_t i = 0; i<n; i++)
- for (size_t j = 0; j < m; ++j)
- mas2[i] += mas1[i][j];
- for (size_t i = 0; i < n - 1; i++)
- for (size_t j = i + 1; j < n; j++)
- if (mas2[i]>mas2[j]) {
- swap(mas2[i], mas2[j]);
- swap(mas1[i], mas1[j]);
- }
- cout << endl << "Resultat:\n";
- for (size_t i = 0; i < n; ++i) {
- for (size_t j = 0; j < m; ++j)
- cout << mas1[i][j] << " ";
- cout << endl;
- }
- for (size_t i = 0; i < n; ++i)
- delete[]mas1[i];
- delete[]mas1;
- delete[]mas2;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement