Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int array1[5][2] = {
- {1, 2},
- {3, 4},
- {5, 6},
- {7, 8},
- {9, 10}
- };
- void transverse(int *target, int *container, int row, int column) {
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < column; j++) {
- *(container + j * row + i) = *(target + i * column + j);
- }
- }
- }
- void printArray(int *target, int row, int column) {
- Serial.println();
- for (int i = 0; i < row; i++) {
- for (int j = 0; j < column; j++) {
- Serial.print(*(target + i * column + j));
- Serial.print("\t");
- }
- Serial.println();
- }
- }
- void setup() {
- Serial.begin(115200);
- printArray((int*)array1, 5, 2);
- int array2[2][5];
- transverse((int*)array1, (int*)array2, 5, 2);
- printArray((int*)array2, 2, 5);
- }
- void loop() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement