#include using namespace std; //https://mindcoding.ro/pb/ggx void xorin() { int n = 0; int m = 0; int x = 0; int pivot = 0; cin >> n >> m >> x; int len = n * m; n = n * x; int lines = n; m = m * x; int cols = m; //the list of read elements int *v = new int[len]; //the output matrix int **a = new int *[n]; for (int i = 0; i < n; i++) a[i] = new int[m]; //read for (int i = 0; i < len; i++) cin >> v[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = v[pivot]; if (((j + 1) % x == 0) && (j + 1) != m) pivot++; } if ((i + 1) % x == 0) pivot++; else pivot=pivot-x+1; } //print the matrix for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << a[i][j] << " "; cout << endl; } } int main() { // givenBack(); xorin(); return 0; }