#include <iostream>
void printArray(int **&arr);
int main()
{
int** array;
int count(0);
array = new int*[5];
for (int i = 0; i < 5; ++i) {
array[i] = new int[5];
}
for (int i = 0; i < 5; ++i) {
for (int q = 0; q < 5; ++q) {
array[i][q] = count;
count += 1;
}
}
printArray(array);
return 0;
}
void printArray(int **&arr)
{
for (int i = 0; i < 5; ++i) {
for (int q = 0; q < 5; ++q) {
std::cout << arr[i][q]<<" ";
}
std::cout << std::endl;
}
}
//[출력결과]
0 1 2 3 4
5 6 7 8 9
10 11 12 13 14
15 16 17 18 19
20 21 22 23 24
반응형