---
# System prepended metadata

title: 11773 - Integer pointer array
tags: [NTHUOJ]

---

# 11773 - Integer pointer array
## 題解:
設一個間隔且此間隔會遞加1, 
每個index都會增加一個間隔
## Code:
```cpp=
#include "function.h"
#include <stdlib.h>

int** malloc_ptr(int array_size){
    return (int**)malloc(array_size * sizeof(int*));
}

void malloc_array(int **array, int array_size){
    *array = (int*)malloc(array_size * sizeof(int));
}

void pointer_ptr_to_array(int *array, int **ptr, int N){
    int idx = 0, k = 0;
    for(int i = 0; i < N; i++){
        ptr[i] = &array[idx];
        k++;
        idx += k;
    }
}
```
###### tags: `NTHUOJ`