Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- const int n = 5, m = 5;
- void fun(int a[]) {
- int b[m][n];
- cout << "\n\nArray#2:\n";
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (m > n)b[j][i] = a[n * i + j];
- else b[j][i] = a[m * i + j];
- cout << b[j][i] << "\t";
- }
- cout << "\n\n";
- }
- cout << "\nArray#2`:\n";
- for (int i = 0; i < m; i++) {
- for (int j = 0; j < n; j++) {
- if (m > n)a[n * i + j] = b[i][j];
- else a[m * i + j] = b[i][j];
- cout << b[i][j] << "\t";
- }
- cout << "\n\n";
- }
- }
- int main() {
- srand(time(0));
- int a[n * m];
- cout << "Array#1:\n";
- for (int i = 0; i < n * m; i++) {
- a[i] = rand() % 10;
- cout << a[i] << " ";
- }
- fun(a);
- cout << "\nArray#1`:\n";
- for (int i = 0; i < n * m; i++) {
- cout << a[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement