Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int arrSize;
- int matrix[100];
- cin >> arrSize;
- for(int i = 0; i < arrSize; i++)
- {
- int num = rand() % 1000 + 1;
- matrix[i] = num;
- cout << matrix[i] << " ";
- }
- cout << endl << endl;
- int temp;
- temp = matrix[0];
- matrix[0] = matrix[arrSize - 1];
- matrix[arrSize - 1] = temp;
- for(int j = 0; j < arrSize; j++)
- {
- cout << matrix[j] << " ";
- }
- cout << endl;
- }
- /*
- ---------------------------------------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------------------------------------
- Generates an array with random numbers and switches the first element with the last.
- ---------------------------------------------------------------------------------------------------------------------------------
- ---------------------------------------------------------------------------------------------------------------------------------
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement