Skip to content

Instantly share code, notes, and snippets.

@henrybear327
Created January 23, 2018 10:51
Show Gist options
  • Save henrybear327/3334dc4db5eb14be79f1c3762ff39eef to your computer and use it in GitHub Desktop.
Save henrybear327/3334dc4db5eb14be79f1c3762ff39eef to your computer and use it in GitHub Desktop.
2D array using new.cpp
#include <bits/stdc++.h>
using namespace std;
int main()
{
static int** Array2D = NULL;
int row = 1000;
int col = 1000;
// make row * col size array
Array2D = new int*[row];
for(int i = 0; i < row; i++)
Array2D[i] = new int[col];
// use it
for(int i = 0; i < row; i++)
for(int j = 0; j < col; j++)
Array2D[i][j] = rand();
printf("%d\n", Array2D[rand() % row][rand() % col]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment