Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- int ySize{ 10 };
- int xSize{ 10 };
- int** arr2d { new int* [ySize] };
- for (int y{ 0 }; y < ySize; ++y)
- {
- arr2d[y] = new int[xSize];
- }
- for (int y{ 0 }; y < ySize; ++y)
- {
- for (int x{ 0 }; x < xSize; ++x)
- {
- arr2d[y][x] = rand() % 10;
- }
- }
- for (int y{ 0 }; y < ySize; ++y)
- {
- for (int x{ 0 }; x < xSize; ++x)
- {
- std::cout << arr2d[y][x] << ' ';
- }
- std::cout << '\n';
- }
- std::cout << '\n';
- delete[] arr2d[ySize - 1];
- int** tmp = new int * [--ySize];
- for (int y{ 0 }; y < ySize; ++y)
- {
- tmp[y] = arr2d[y];
- }
- delete[] arr2d;
- arr2d = tmp;
- std::cout << "New ySize is: " << ySize << "\n\n";
- for (int y{ 0 }; y < ySize; ++y)
- {
- for (int x{ 0 }; x < xSize; ++x)
- {
- std::cout << arr2d[y][x] << ' ';
- }
- std::cout << '\n';
- }
- std::cout << '\n';
- for (int y{ 0 }; y < ySize; ++y)
- {
- delete[] arr2d[y];
- }
- delete[] arr2d;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement