Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h> /* srand, rand */
- #include <time.h> /* time */
- using namespace std;
- int A[10][10], n, m, k, aux;
- void afisare() {
- cout << endl;
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= n; j++)
- cout << A[i][j] << " ";
- cout << endl;
- }
- cout << endl;
- }
- int main()
- {
- cout << "k: "; cin >> k;
- cout << "n: "; cin >> n;
- /* initialize random seed: */
- srand(time(NULL));
- /* generate secret number between 1 and 10: */
- int nrGeneratRandom;
- for (int i = 1; i <= n; i++)
- {
- for (int j = 1; j <= n; j++)
- {
- nrGeneratRandom = rand() % 7 + 1;
- A[i][j] = nrGeneratRandom; //Introducere date in matrice
- }
- }
- afisare();
- /*Interschimbarea*/
- for (int coloana = 1; coloana < n; coloana++)
- {
- aux = A[k][coloana];
- A[k][coloana] = A[coloana][k];
- A[coloana][k] = aux;
- }
- afisare();
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment