Created
May 22, 2013 07:11
-
-
Save iodiot/5625781 to your computer and use it in GitHub Desktop.
This file contains 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 <iostream> | |
using namespace std; | |
int main() | |
{ | |
int x = 10; | |
int y = 10; | |
int **a; | |
// create array | |
a = new int*[x]; | |
for (int i = 0; i < x; ++i) | |
a[i] = new int[y]; | |
// fill array | |
for (int i = 0; i < x; ++i) | |
for (int j = 0; j < y; ++j) | |
a[i][j] = i * j; | |
// test array | |
char s[0xff]; | |
sprintf(s, "a[0][0] = %d\na[5][5] = %d\n", a[0][0], a[5][5]); | |
cout << s; | |
// free array | |
for (int i = 0; i < x; ++i) | |
delete[] a[i]; | |
delete[] a; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment