I don't even rememeber what I changed between now and last commit

This commit is contained in:
2024-03-18 18:11:48 -05:00
parent debcca3729
commit f39848f9b3
174 changed files with 16569 additions and 2577 deletions

View File

@@ -0,0 +1,49 @@
#include <iostream>
using namespace std;
#include "twoDArrays.h"
/** Create a 2D dynamic array and return it.
Use indexes in creation*/
int** create2DArray1(int rows, int columns) {
int** pp = new int*[rows];
for (int i = 0; i < rows; ++i) {
pp[i] = new int[columns];
}
return pp;
}
/** Create a 2D dynamic array and return it.
Use offset in creation*/
int** create2DArray2(int rows, int columns) {
int** pp = new int*[rows];
for (int i = 0; i < rows; ++i) {
(**pp + i) = new int[columns];
}
return pp;
}
/* Populate the 2D array with arbitrary integers using a loop*/
void populate (int** pp, int rows, int columns) {
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < columns; ++j) {
pp[i][j] = (i + 1) * j;
}
}
}
/*Traverse the 2D array using indexes inside a loop*/
void traverse(int** pp, int rows, int columns) {
for(int i = 0; i < rows; ++i) {
for (int j = 0; j < columns; ++j) {
cout << pp[i][j] << " ";
cout << endl;
}
}
/*Traverse the 2D array by de-referencing the pointers inside a loop*/
void traverse1( int** pp, int rows, int columns);
/** Free the memory the 2D array*/
void freeMemory( int** pp, int rows);
}