Created
January 23, 2018 10:51
-
-
Save henrybear327/3334dc4db5eb14be79f1c3762ff39eef to your computer and use it in GitHub Desktop.
2D array using new.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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