Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<iomanip>
- #include<ctime>
- using namespace std;
- void main()
- {
- srand(time(NULL));
- //const int n = 20;
- long int n = rand() % 5000;
- int **mas = new int*[n];
- int k = rand() % n;
- //int mas[n][n];
- for (int i = 0; i < n; i++)
- {
- mas[i] = new int[n];
- for (int j = 0; j < n; j++)
- mas[i][j] = rand() % 2000 - 100;
- }
- cout << "Source array:" << endl;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- cout << setw(4) << mas[i][j];
- cout << endl;
- }
- //cout << "Enter number of column:";
- //cin >> k;
- for (int i = 0; i<n; i++)
- for (int j = 0; j < n; j++) {
- if (i == k) mas[i][j] = mas[j][k];
- else
- {
- mas[i][j] = mas[i][j];
- }
- }
- cout << "Result array:" << endl;
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < n; j++)
- cout << setw(4) << mas[i][j];
- cout << endl;
- }
- for (int i = 0; i < n; i++) {
- delete[]mas[i];
- }
- delete[]mas;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement