From d607fb1eee18c68187fe4bedbf0ea3661e52b266 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 12:54:36 +0300 Subject: [PATCH 01/20] feat(07-l3): 01-random-matrix --- 07-Algorithms-L3/01-random-matrix.cpp | 40 ++++++ 07-Algorithms-L3/07-Algorithms-L3.slnx | 7 + 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 135 ++++++++++++++++++ .../07-Algorithms-L3.vcxproj.filters | 22 +++ Engineering-Logic-Roadmap.slnx | 1 + 5 files changed, 205 insertions(+) create mode 100644 07-Algorithms-L3/01-random-matrix.cpp create mode 100644 07-Algorithms-L3/07-Algorithms-L3.slnx create mode 100644 07-Algorithms-L3/07-Algorithms-L3.vcxproj create mode 100644 07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters diff --git a/07-Algorithms-L3/01-random-matrix.cpp b/07-Algorithms-L3/01-random-matrix.cpp new file mode 100644 index 0000000..1d76701 --- /dev/null +++ b/07-Algorithms-L3/01-random-matrix.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + return 0; +} \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.slnx b/07-Algorithms-L3/07-Algorithms-L3.slnx new file mode 100644 index 0000000..697c6a8 --- /dev/null +++ b/07-Algorithms-L3/07-Algorithms-L3.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj new file mode 100644 index 0000000..3f18995 --- /dev/null +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 18.0 + Win32Proj + {4bc62c83-1fc7-4227-bc34-d3838b6a9bd7} + My07AlgorithmsL3 + 10.0 + + + + Application + true + v145 + Unicode + + + Application + false + v145 + true + Unicode + + + Application + true + v145 + Unicode + + + Application + false + v145 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp20 + + + Console + true + + + + + + + + + \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters new file mode 100644 index 0000000..a74b122 --- /dev/null +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/Engineering-Logic-Roadmap.slnx b/Engineering-Logic-Roadmap.slnx index 07ca0e7..afa3a64 100644 --- a/Engineering-Logic-Roadmap.slnx +++ b/Engineering-Logic-Roadmap.slnx @@ -12,4 +12,5 @@ + From 380e0ad4e142c388e5484c719159b9f18548ec2c Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 13:10:45 +0300 Subject: [PATCH 02/20] feat(07-l3): 02-sum-each-row-in-matrix --- .../02-sum-each-row-in-matrix.cpp | 59 +++++++++++++++++++ 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/02-sum-each-row-in-matrix.cpp diff --git a/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp b/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp new file mode 100644 index 0000000..da0de2e --- /dev/null +++ b/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp @@ -0,0 +1,59 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int sumArr(int arr[3], int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += arr[i]; + } + return sum; +} + +void printMatrixRowsSum(int matrix[3][3], int rows, int cols) { + std::cout << "\n The following are the sums of each row in the matrix: " << std::endl; + for (int i = 0; i < rows; i++) { + int sum = sumArr(matrix[i], cols); + std::cout << "The Sum of row " << std::to_string(i+1) << " is: " << sum << std::endl; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + printMatrixRowsSum(matrix, rows, cols); + + + return 0; +} \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 3f18995..9a6af6a 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -127,7 +127,10 @@ - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index a74b122..cdfe61f 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -18,5 +18,8 @@ Source Files + + Source Files + \ No newline at end of file From 2a74f97e0d1ee952dedb4c4d14471342e541e6db Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 13:24:47 +0300 Subject: [PATCH 03/20] feat(07-l3): 03-sum-each-row-in-matrix-in-array --- .../02-sum-each-row-in-matrix.cpp | 2 +- .../03-sum-each-row-in-matrix-in-array.cpp | 76 +++++++++++++++++++ 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 4 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 07-Algorithms-L3/03-sum-each-row-in-matrix-in-array.cpp diff --git a/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp b/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp index da0de2e..d771037 100644 --- a/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp +++ b/07-Algorithms-L3/02-sum-each-row-in-matrix.cpp @@ -36,7 +36,7 @@ int sumArr(int arr[3], int length) { } void printMatrixRowsSum(int matrix[3][3], int rows, int cols) { - std::cout << "\n The following are the sums of each row in the matrix: " << std::endl; + std::cout << "\nThe following are the sums of each row in the matrix: " << std::endl; for (int i = 0; i < rows; i++) { int sum = sumArr(matrix[i], cols); std::cout << "The Sum of row " << std::to_string(i+1) << " is: " << sum << std::endl; diff --git a/07-Algorithms-L3/03-sum-each-row-in-matrix-in-array.cpp b/07-Algorithms-L3/03-sum-each-row-in-matrix-in-array.cpp new file mode 100644 index 0000000..ce41965 --- /dev/null +++ b/07-Algorithms-L3/03-sum-each-row-in-matrix-in-array.cpp @@ -0,0 +1,76 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int sumArr(int arr[3], int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += arr[i]; + } + return sum; +} + +void printMatrixRowsSum(int matrix[3][3], int rows, int cols) { + std::cout << "\nThe following are the sums of each row in the matrix: " << std::endl; + for (int i = 0; i < rows; i++) { + int sum = sumArr(matrix[i], cols); + std::cout << "The Sum of row " << std::to_string(i + 1) << " is: " << sum << std::endl; + } +} + +void fillSumsArrayFromMatrix(int matrix[3][3], int rows, int cols, int sumsArray[3]) { + for (int i = 0; i < rows; i++) { + sumsArray[i] = sumArr(matrix[i], cols); + } +} + +void printSumsArray(int sumsArray[3], int length) { + std::cout << "\nThe following are the sums of each row in the matrix: " << std::endl; + for (int i = 0; i < length; i++) { + std::cout << "The Sum of row " << std::to_string(i + 1) << " is: " << sumsArray[i] << std::endl; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + int sums[3] = {}; + int sumsLength = 3; + + fillSumsArrayFromMatrix(matrix, rows, cols, sums); + printSumsArray(sums, sumsLength); + + + return 0; +} \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 9a6af6a..2c4632a 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -130,7 +130,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index cdfe61f..a4e7409 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -21,5 +21,8 @@ Source Files + + Source Files + \ No newline at end of file From 3cceeeb76aa45ace479b2e5bff310e232ea9aab2 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 13:41:38 +0300 Subject: [PATCH 04/20] feat(07-l3): 04-sum-each-col-in-matrix --- .../04-sum-each-col-in-matrix.cpp | 67 +++++++++++++++++++ 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/04-sum-each-col-in-matrix.cpp diff --git a/07-Algorithms-L3/04-sum-each-col-in-matrix.cpp b/07-Algorithms-L3/04-sum-each-col-in-matrix.cpp new file mode 100644 index 0000000..23e53a7 --- /dev/null +++ b/07-Algorithms-L3/04-sum-each-col-in-matrix.cpp @@ -0,0 +1,67 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int sumArr(int arr[3], int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += arr[i]; + } + return sum; +} + +int sumCols(int matrix[3][3], int col, int rows) { + int colsSum = 0; + for (int i = 0; i < rows; i++) { + colsSum += matrix[i][col]; + } + return colsSum; +} + +void printMatrixColsSum(int matrix[3][3], int rows, int cols) { + std::cout << "\nThe following are the sums of each column in the matrix: " << std::endl; + + for (int i = 0; i < cols; i++){ + std::cout << "Col " + std::to_string(i + 1) + " Sum is: " + std::to_string(sumCols(matrix, i, rows)) << std::endl; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + printMatrixColsSum(matrix, rows, cols); + + + return 0; +} \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 2c4632a..8d7850a 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -133,7 +133,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index a4e7409..b5de730 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -24,5 +24,8 @@ Source Files + + Source Files + \ No newline at end of file From 766fc9a9db690445e1892f392d1184fbbbf48862 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 13:53:19 +0300 Subject: [PATCH 05/20] feat(07-l3): 05-sum-each-col-in-matrix-in-another-array --- ...um-each-col-in-matrix-in-another-array.cpp | 82 +++++++++++++++++++ 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/05-sum-each-col-in-matrix-in-another-array.cpp diff --git a/07-Algorithms-L3/05-sum-each-col-in-matrix-in-another-array.cpp b/07-Algorithms-L3/05-sum-each-col-in-matrix-in-another-array.cpp new file mode 100644 index 0000000..d8d79f5 --- /dev/null +++ b/07-Algorithms-L3/05-sum-each-col-in-matrix-in-another-array.cpp @@ -0,0 +1,82 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int sumArr(int arr[3], int length) { + int sum = 0; + for (int i = 0; i < length; i++) { + sum += arr[i]; + } + return sum; +} + +int sumCols(int matrix[3][3], int col, int rows) { + int colsSum = 0; + for (int i = 0; i < rows; i++) { + colsSum += matrix[i][col]; + } + return colsSum; +} + +void printMatrixColsSum(int matrix[3][3], int rows, int cols) { + std::cout << "\nThe following are the sums of each column in the matrix: " << std::endl; + + for (int i = 0; i < cols; i++) { + std::cout << "Col " + std::to_string(i + 1) + " Sum is: " + std::to_string(sumCols(matrix, i, rows)) << std::endl; + } +} + +void fillArrayWithColsSumsFromMatrix(int matrix[3][3], int rows, int cols, int colsSums[3]) { + for (int i = 0; i < cols; i++) { + colsSums[i] = sumCols(matrix, i, rows); + } +} +void printColsSumsArray(int arr[3], int length) { + std::cout << "\nThe following are the sums of each column in the matrix: " << std::endl; + for (int i = 0; i < length; i++) { + std::cout << "Col " + std::to_string(i + 1) + " Sum is: " + std::to_string(arr[i]) << std::endl; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + int colsSums[3]; + int colsSumsLength = 3; + + fillArrayWithColsSumsFromMatrix(matrix, rows, cols, colsSums); + printColsSumsArray(colsSums, colsSumsLength); + + return 0; +} \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 8d7850a..9d87a75 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -136,7 +136,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index b5de730..90e21fb 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -27,5 +27,8 @@ Source Files + + Source Files + \ No newline at end of file From 8ba64e344997fe64527a6434b05b39fb288c7854 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 14:39:22 +0300 Subject: [PATCH 06/20] feat(07-l3): 06-value-ordered-matrix --- 07-Algorithms-L3/06-ordered-matrix.cpp | 37 +++++++++++++++++++ 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 ++- .../07-Algorithms-L3.vcxproj.filters | 3 ++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/06-ordered-matrix.cpp diff --git a/07-Algorithms-L3/06-ordered-matrix.cpp b/07-Algorithms-L3/06-ordered-matrix.cpp new file mode 100644 index 0000000..5820e6f --- /dev/null +++ b/07-Algorithms-L3/06-ordered-matrix.cpp @@ -0,0 +1,37 @@ +#include +#include +#include + + +void fillMatrixWithOrderedNumbers(int matrix[3][3], int rows, int cols) { + int n = 0; + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + n++; + matrix[i][j] = n; + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 ordered matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int main() { + + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithOrderedNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + return 0; +} \ No newline at end of file diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 9d87a75..b817abd 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -139,7 +139,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 90e21fb..ff623b7 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -30,5 +30,8 @@ Source Files + + Source Files + \ No newline at end of file From 5aa728f3007ba4d8efe80c72d8d3ea419d668d07 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 15:12:03 +0300 Subject: [PATCH 07/20] feat(07-l3): 07-traspose-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 ++ 07-Algorithms-L3/07-traspose-matrix.cpp | 51 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/07-traspose-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index b817abd..196d532 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -142,7 +142,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index ff623b7..577994c 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -33,5 +33,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/07-traspose-matrix.cpp b/07-Algorithms-L3/07-traspose-matrix.cpp new file mode 100644 index 0000000..2e2e885 --- /dev/null +++ b/07-Algorithms-L3/07-traspose-matrix.cpp @@ -0,0 +1,51 @@ +#include +#include +#include + + +void fillMatrixWithOrderedNumbers(int matrix[3][3], int rows, int cols) { + int n = 0; + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + n++; + matrix[i][j] = n; + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 ordered matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +void trasposeMatrix(int matrix[3][3], int rows, int cols, int trasposed[3][3]) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + trasposed[j][i] = matrix[i][j]; + } + } +} + +int main() { + + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithOrderedNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + int trasposed[3][3] = {}; + int tRows = 3, tCols = 3; + trasposeMatrix(matrix, rows, cols, trasposed); + printMatrix(trasposed, tRows, tCols); + return 0; +} \ No newline at end of file From 8eae9a18d96a3fad7a5aa7ef8b4c960164aa0970 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 15:25:54 +0300 Subject: [PATCH 08/20] feat(07-l3): 08-multiply-two-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 07-Algorithms-L3/08-multiply-two-matrix.cpp | 61 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/08-multiply-two-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 196d532..adf9611 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -145,7 +145,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 577994c..644ec1b 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -36,5 +36,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/08-multiply-two-matrix.cpp b/07-Algorithms-L3/08-multiply-two-matrix.cpp new file mode 100644 index 0000000..6a951a3 --- /dev/null +++ b/07-Algorithms-L3/08-multiply-two-matrix.cpp @@ -0,0 +1,61 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols, std::string message) { + std::cout << message; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +void multiply2MatrixInto(int resultsMatrix[3][3], int matrix1[3][3], int matrix2[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + resultsMatrix[i][j] = matrix1[i][j] * matrix2[i][j]; + } + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols, "\nMatrix1:\n"); + + int matrix2[3][3] = {}; + int rows2 = 3, cols2 = 3; + + fillMatrixWithRandomNumbers(matrix2, rows2, cols2); + printMatrix(matrix2, rows2, cols2, "\nMatrix2:\n"); + + int resultsMatrix[3][3] = {}; + int resultsRows = 3, resultsCols = 3; + + multiply2MatrixInto(resultsMatrix, matrix, matrix2, rows, cols); + printMatrix(resultsMatrix, resultsRows, resultsCols, "\nResults:\n"); + return 0; +} \ No newline at end of file From a19d06946c06247eb5284f27e0747b1e3faa6c6e Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 15:37:45 +0300 Subject: [PATCH 09/20] feat(07-l3): 09-print-middle-row-and-col-of-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + .../09-print-middle-row-and-col-of-matrix.cpp | 58 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/09-print-middle-row-and-col-of-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index adf9611..645ff4f 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -148,7 +148,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 644ec1b..572d99b 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -39,5 +39,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/09-print-middle-row-and-col-of-matrix.cpp b/07-Algorithms-L3/09-print-middle-row-and-col-of-matrix.cpp new file mode 100644 index 0000000..bf5811a --- /dev/null +++ b/07-Algorithms-L3/09-print-middle-row-and-col-of-matrix.cpp @@ -0,0 +1,58 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +void printMiddleRow(int matrix[3][3], int rows, int cols) { + int middleRow = rows / 2; + std::cout << "The middle Row is: " << std::endl; + for (int i = 0; i < cols; i++) { + std::cout << matrix[middleRow][i] << std::setw(3) << "\t"; + } +} + +void printMiddleCol(int matrix[3][3], int rows, int cols) { + int middleCol = cols / 2; + std::cout << "\nThe middle Col is: " << std::endl; + for (int i = 0; i < rows; i++) { + std::cout << matrix[i][middleCol] << std::setw(3) << "\t"; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + printMiddleRow(matrix, rows, cols); + printMiddleCol(matrix, rows, cols); + return 0; +} \ No newline at end of file From 4e1c42e9071876c745e1ac3e90f7625622cecea3 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 15:42:14 +0300 Subject: [PATCH 10/20] feat(07-l3): 10-sum-of-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 ++ 07-Algorithms-L3/10-sum-of-matrix.cpp | 52 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/10-sum-of-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 645ff4f..ef009ae 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -151,7 +151,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 572d99b..66a5381 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -42,5 +42,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/10-sum-of-matrix.cpp b/07-Algorithms-L3/10-sum-of-matrix.cpp new file mode 100644 index 0000000..5f10b12 --- /dev/null +++ b/07-Algorithms-L3/10-sum-of-matrix.cpp @@ -0,0 +1,52 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +void printSumOfMatrix(int matrix[3][3], int rows, int cols) { + int sum = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + sum += matrix[i][j]; + } + } + std::cout << "\nSum of the matrix: " << std::to_string(sum) << std::endl; +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + printSumOfMatrix(matrix, rows, cols); + + return 0; +} \ No newline at end of file From 5bde2f18fec6033d65335adfa1316840db44bcc5 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 16:20:16 +0300 Subject: [PATCH 11/20] feat(07-l3): 11-check-matrices-equality --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + .../11-check-matrieces-equality.cpp | 74 +++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/11-check-matrieces-equality.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index ef009ae..f66b27b 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -154,7 +154,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 66a5381..5a8db1d 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -45,5 +45,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/11-check-matrieces-equality.cpp b/07-Algorithms-L3/11-check-matrieces-equality.cpp new file mode 100644 index 0000000..a34852e --- /dev/null +++ b/07-Algorithms-L3/11-check-matrieces-equality.cpp @@ -0,0 +1,74 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int calcSumOfMatrix(int matrix[3][3], int rows, int cols) { + int sum = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + sum += matrix[i][j]; + } + } + return sum; +} + +void printSumOfMatrix(int matrix[3][3], int rows, int cols) { + int sum = calcSumOfMatrix(matrix, rows, cols); + std::cout << "\nSum of the matrix: " << std::to_string(sum) << std::endl; +} + +void printMatricesSumEqual(int matrix1[3][3], int rows, int cols, int matrix2[3][3]) { + int sum1 = calcSumOfMatrix(matrix1, rows, cols); + int sum2 = calcSumOfMatrix(matrix2, rows, cols); + std::string equal = (sum1 == sum2) ? "Equal" : "Not Equal"; + std::cout << "\nMatices Are " + equal; +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + printSumOfMatrix(matrix, rows, cols); + + int matrix2[3][3] = {}; + int rows2 = 3, cols2 = 3; + + fillMatrixWithRandomNumbers(matrix2, rows2, cols2); + printMatrix(matrix2, rows2, cols2); + + printSumOfMatrix(matrix2, rows2, cols2); + + printMatricesSumEqual(matrix, rows, cols, matrix2); + + return 0; +} \ No newline at end of file From 80066034ea7d6d34426233bac005f1800e2700f2 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 16:33:21 +0300 Subject: [PATCH 12/20] feat(07-l3): 12-check-typical-matrices --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + .../12-check-typical-matrices.cpp | 71 +++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/12-check-typical-matrices.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index f66b27b..39db19a 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -157,7 +157,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 5a8db1d..1ac32cb 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -48,5 +48,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/12-check-typical-matrices.cpp b/07-Algorithms-L3/12-check-typical-matrices.cpp new file mode 100644 index 0000000..64ee906 --- /dev/null +++ b/07-Algorithms-L3/12-check-typical-matrices.cpp @@ -0,0 +1,71 @@ +#include +#include +#include + +int generateRandomIntegerInRange(int min, int max) { + return rand() % (max - min + 1) + min; +} + +void fillMatrixWithRandomNumbers(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + matrix[i][j] = generateRandomIntegerInRange(1, 100); + } + } +} + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +void printCheckTypicalMatrices(int matrix1[3][3], int matrix2[3][3], int rows, int cols) { + bool isTypical = true; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + if (matrix1[i][j] != matrix2[i][j]) { + isTypical = false; + break; + + } + std::cout << i << " "; + } + } + if (isTypical) { + std::cout << "\nYes, Matrices Are Typical"; + } + else { + std::cout << "\nNo, Matrices Are Not Typical"; + } +} + +int main() { + //Seeds the random number generator in C++, called only once + srand((unsigned)time(NULL)); + int matrix[3][3] = {}; + int rows = 3, cols = 3; + + fillMatrixWithRandomNumbers(matrix, rows, cols); + printMatrix(matrix, rows, cols); + + + + int matrix2[3][3] = {}; + int rows2 = 3, cols2 = 3; + + fillMatrixWithRandomNumbers(matrix2, rows2, cols2); + printMatrix(matrix2, rows2, cols2); + + printCheckTypicalMatrices(matrix, matrix2, rows, cols); + + + return 0; +} \ No newline at end of file From 9d330605b3b793fee2619bae07d6f20da4078325 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 16:46:58 +0300 Subject: [PATCH 13/20] feat(07-l3): 13-check-identity-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 ++- .../07-Algorithms-L3.vcxproj.filters | 3 ++ .../12-check-typical-matrices.cpp | 1 - 07-Algorithms-L3/13-check-identity-matrix.cpp | 39 +++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 07-Algorithms-L3/13-check-identity-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 39db19a..bd7ee07 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -160,7 +160,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 1ac32cb..3fe5d1a 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -51,5 +51,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/12-check-typical-matrices.cpp b/07-Algorithms-L3/12-check-typical-matrices.cpp index 64ee906..14c4d7b 100644 --- a/07-Algorithms-L3/12-check-typical-matrices.cpp +++ b/07-Algorithms-L3/12-check-typical-matrices.cpp @@ -36,7 +36,6 @@ void printCheckTypicalMatrices(int matrix1[3][3], int matrix2[3][3], int rows, i break; } - std::cout << i << " "; } } if (isTypical) { diff --git a/07-Algorithms-L3/13-check-identity-matrix.cpp b/07-Algorithms-L3/13-check-identity-matrix.cpp new file mode 100644 index 0000000..eec1ae0 --- /dev/null +++ b/07-Algorithms-L3/13-check-identity-matrix.cpp @@ -0,0 +1,39 @@ +#include + + +bool checkIsIdentityMatrix(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + + if (i == j && matrix[i][j] != 1) { + return false; + } + else if (i != j && matrix[i][j] != 0) { + return false; + } + + } + } + return true; +} + +int main() { + int matrix[3][3] = { + {1, 0, 0}, + {0, 1, 0}, + {0, 0, 1} + }; + int rows = 3, cols = 3; + + bool isIdentity = checkIsIdentityMatrix(matrix, rows, cols); + + + if (isIdentity) + std::cout << "\nYES: Matrix is identity."; + else + std::cout << "\nNo: Matrix is NOT identity."; + + return 0; +} \ No newline at end of file From a611525d0c9987a2a73e93731473647b4c435659 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Tue, 24 Feb 2026 16:52:32 +0300 Subject: [PATCH 14/20] feat(07-l3): 13-check-scalar-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 ++- .../07-Algorithms-L3.vcxproj.filters | 3 ++ 07-Algorithms-L3/14-check-scalar-matrix.cpp | 39 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/14-check-scalar-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index bd7ee07..65ca657 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -163,7 +163,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 3fe5d1a..85c7544 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -54,5 +54,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/14-check-scalar-matrix.cpp b/07-Algorithms-L3/14-check-scalar-matrix.cpp new file mode 100644 index 0000000..19fa514 --- /dev/null +++ b/07-Algorithms-L3/14-check-scalar-matrix.cpp @@ -0,0 +1,39 @@ +#include + + +bool isScalarMatrix(int matrix[3][3], int rows, int cols) { + int first = matrix[0][0]; + for (int i = 0; i < rows; i++) { + + for (int j = 0; j < cols; j++) { + + if (i == j && matrix[i][j] != first) { + return false; + } + else if (i != j && matrix[i][j] != 0) { + return false; + } + + } + } + return true; +} + +int main() { + int matrix[3][3] = { + {1, 0, 0}, + {0, 1, 0}, + {0, 0, 1} + }; + int rows = 3, cols = 3; + + bool isIdentity = isScalarMatrix(matrix, rows, cols); + + + if (isIdentity) + std::cout << "\nYES: Matrix is Scalar."; + else + std::cout << "\nNo: Matrix is NOT Scalar."; + + return 0; +} \ No newline at end of file From 511eacb1be5bf02cd1258534cace98d258c21f18 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Wed, 25 Feb 2026 08:20:26 +0300 Subject: [PATCH 15/20] feat(07-l3): 15-count-number-in-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + .../15-count-number-in-matrix.cpp | 60 +++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/15-count-number-in-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 65ca657..d6c7714 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -166,7 +166,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 85c7544..e1a7517 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -57,5 +57,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/15-count-number-in-matrix.cpp b/07-Algorithms-L3/15-count-number-in-matrix.cpp new file mode 100644 index 0000000..6509b1b --- /dev/null +++ b/07-Algorithms-L3/15-count-number-in-matrix.cpp @@ -0,0 +1,60 @@ +#include +#include + + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int readNumber() +{ + int number; + std::cout << "Please enter a number?" << std::endl; + std::cin >> number; + while (std::cin.fail()) + { + // user didn't input a number + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + std::cout << "Invalid Number, Enter a valid one:" << std::endl; + std::cin >> number; + } + return number; +} + +int countNumberInMatrix(int matrix[3][3], int rows, int cols, int numberToCount) { + int count = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + if(matrix[i][j] == numberToCount) count++; + } + } + return count; +} + +int main() { + + int matrix[3][3] = { + {1, 0, 2}, + {2, 3, 4}, + {4, 5, 4} + }; + int rows = 3, cols = 3; + + printMatrix(matrix, rows, cols); + + int numberToCount = readNumber(); + + int count = countNumberInMatrix(matrix, rows, cols, numberToCount); + + printf("\nThe number %d appeared in the matrix %d times.", numberToCount, count); + + return 0; +} \ No newline at end of file From d202f960a3ef08aea24d225668ddf670f0e028c0 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Wed, 25 Feb 2026 08:31:02 +0300 Subject: [PATCH 16/20] feat(07-l3): 16-check-sparse-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 07-Algorithms-L3/16-check-sparse-matrix.cpp | 64 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/16-check-sparse-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index d6c7714..23da684 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -169,7 +169,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index e1a7517..5d68405 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -60,5 +60,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/16-check-sparse-matrix.cpp b/07-Algorithms-L3/16-check-sparse-matrix.cpp new file mode 100644 index 0000000..0946887 --- /dev/null +++ b/07-Algorithms-L3/16-check-sparse-matrix.cpp @@ -0,0 +1,64 @@ +#include +#include + + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int readNumber() +{ + int number; + std::cout << "Please enter a number?" << std::endl; + std::cin >> number; + while (std::cin.fail()) + { + // user didn't input a number + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + std::cout << "Invalid Number, Enter a valid one:" << std::endl; + std::cin >> number; + } + return number; +} + +int countNumberInMatrix(int matrix[3][3], int rows, int cols, int numberToCount) { + int count = 0; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + if (matrix[i][j] == numberToCount) count++; + } + } + return count; +} + +bool isMatrixSparse(int matrix[3][3], int rows, int cols) { + int zerosCount = countNumberInMatrix(matrix, rows, cols, 0); + return (zerosCount > ((rows * cols / 2) + 1)); +} + +int main() { + + int matrix[3][3] = { + {1, 0, 2}, + {2, 3, 4}, + {4, 5, 4} + }; + int rows = 3, cols = 3; + + printMatrix(matrix, rows, cols); + + int numberToCount = readNumber(); + + bool isSparse = isMatrixSparse(matrix, rows, cols); + + (isSparse) ? std::cout << "\nYes, The matrix is a sparse" : std::cout << "\nNo, The matrix is not a sparse"; + return 0; +} \ No newline at end of file From 5446e6c1145f7c76158d7a328c8f7adf0a56465d Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Wed, 25 Feb 2026 08:42:44 +0300 Subject: [PATCH 17/20] feat(07-l3): 17-number-exist-in-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + 07-Algorithms-L3/16-check-sparse-matrix.cpp | 20 +------ .../17-number-exist-in-matrix.cpp | 59 +++++++++++++++++++ 4 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 07-Algorithms-L3/17-number-exist-in-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 23da684..748fb6e 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -172,7 +172,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 5d68405..9338eaa 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -63,5 +63,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/16-check-sparse-matrix.cpp b/07-Algorithms-L3/16-check-sparse-matrix.cpp index 0946887..dc870f2 100644 --- a/07-Algorithms-L3/16-check-sparse-matrix.cpp +++ b/07-Algorithms-L3/16-check-sparse-matrix.cpp @@ -13,22 +13,6 @@ void printMatrix(int matrix[3][3], int rows, int cols) { } } -int readNumber() -{ - int number; - std::cout << "Please enter a number?" << std::endl; - std::cin >> number; - while (std::cin.fail()) - { - // user didn't input a number - std::cin.clear(); - std::cin.ignore(std::numeric_limits::max(), '\n'); - std::cout << "Invalid Number, Enter a valid one:" << std::endl; - std::cin >> number; - } - return number; -} - int countNumberInMatrix(int matrix[3][3], int rows, int cols, int numberToCount) { int count = 0; for (int i = 0; i < rows; i++) { @@ -41,7 +25,7 @@ int countNumberInMatrix(int matrix[3][3], int rows, int cols, int numberToCount) bool isMatrixSparse(int matrix[3][3], int rows, int cols) { int zerosCount = countNumberInMatrix(matrix, rows, cols, 0); - return (zerosCount > ((rows * cols / 2) + 1)); + return (zerosCount >= ((rows * cols / 2))); } int main() { @@ -55,8 +39,6 @@ int main() { printMatrix(matrix, rows, cols); - int numberToCount = readNumber(); - bool isSparse = isMatrixSparse(matrix, rows, cols); (isSparse) ? std::cout << "\nYes, The matrix is a sparse" : std::cout << "\nNo, The matrix is not a sparse"; diff --git a/07-Algorithms-L3/17-number-exist-in-matrix.cpp b/07-Algorithms-L3/17-number-exist-in-matrix.cpp new file mode 100644 index 0000000..e94cb00 --- /dev/null +++ b/07-Algorithms-L3/17-number-exist-in-matrix.cpp @@ -0,0 +1,59 @@ +#include +#include + + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int readNumber() +{ + int number; + std::cout << "Please enter a number?" << std::endl; + std::cin >> number; + while (std::cin.fail()) + { + // user didn't input a number + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + std::cout << "Invalid Number, Enter a valid one:" << std::endl; + std::cin >> number; + } + return number; +} + +bool isMatrixConatins(int numberToCheck, int matrix[3][3], int rows, int cols) { + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + if (matrix[i][j] == numberToCheck) return true; + } + } + return false; +} + +int main() { + + int matrix[3][3] = { + {1, 0, 2}, + {2, 3, 4}, + {4, 5, 4} + }; + int rows = 3, cols = 3; + + printMatrix(matrix, rows, cols); + + int numberToCheck = readNumber(); + + bool isExist = isMatrixConatins(numberToCheck, matrix, rows, cols); + (isExist) ? printf("\nThe number %d appeared in the matrix", numberToCheck) : + printf("\nThe number %d not exist in the matrix"); + + return 0; +} \ No newline at end of file From 5c057bf0d283a72c9a84a8c69bdfe484d805ecaa Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Wed, 25 Feb 2026 08:56:10 +0300 Subject: [PATCH 18/20] feat(07-l3): 18-intersected-numbers-in-matrices --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + .../18-intersected-numbers-in-matrices.cpp | 74 +++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/18-intersected-numbers-in-matrices.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 748fb6e..a2db759 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -175,7 +175,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 9338eaa..7787ee4 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -66,5 +66,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/18-intersected-numbers-in-matrices.cpp b/07-Algorithms-L3/18-intersected-numbers-in-matrices.cpp new file mode 100644 index 0000000..b879a2e --- /dev/null +++ b/07-Algorithms-L3/18-intersected-numbers-in-matrices.cpp @@ -0,0 +1,74 @@ +#include +#include + + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int readNumber() +{ + int number; + std::cout << "Please enter a number?" << std::endl; + std::cin >> number; + while (std::cin.fail()) + { + // user didn't input a number + std::cin.clear(); + std::cin.ignore(std::numeric_limits::max(), '\n'); + std::cout << "Invalid Number, Enter a valid one:" << std::endl; + std::cin >> number; + } + return number; +} + +bool isMatrixContains(int numberToCheck, int matrix[3][3], int rows, int cols) { + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + if (matrix[i][j] == numberToCheck) return true; + } + } + return false; +} + +void printIntersectedNumbers(int matrix1[3][3], int matrix2[3][3], int rows, int cols) { + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + int numberToCheck = matrix1[i][j]; + if (isMatrixContains(numberToCheck, matrix2, rows, cols)) { + std::cout << std::setw(3) << numberToCheck << "\t"; + } + } + } +} + +int main() { + + int matrix[3][3] = { + {1, 0, 2}, + {2, 3, 4}, + {4, 5, 4} + }; + int rows = 3, cols = 3; + + printMatrix(matrix, rows, cols); + + int matrix2[3][3] = { + {2, 4, 1}, + {3, 6, 5}, + {2, 2, 2} + }; + printMatrix(matrix2, 3, 3); + + std::cout << std::endl; + printIntersectedNumbers(matrix, matrix2, rows, cols); + + return 0; +} \ No newline at end of file From 90cac4a66d5302437f562eb4d5d4574b1ebda961 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Wed, 25 Feb 2026 09:08:06 +0300 Subject: [PATCH 19/20] feat(07-l3): 19-min-max-number-in-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 + .../19-min-max-number-in-matrix.cpp | 64 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/19-min-max-number-in-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index a2db759..9d705ba 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -178,7 +178,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 7787ee4..4d89690 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -69,5 +69,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/19-min-max-number-in-matrix.cpp b/07-Algorithms-L3/19-min-max-number-in-matrix.cpp new file mode 100644 index 0000000..061fdd7 --- /dev/null +++ b/07-Algorithms-L3/19-min-max-number-in-matrix.cpp @@ -0,0 +1,64 @@ +#include +#include + + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +int getMaxNumberFrom(int matrix[3][3], int rows, int cols) { + int max = matrix[0][0]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + int currentNumber = matrix[i][j]; + if (currentNumber > max) { + max = currentNumber; + } + } + } + return max; +} + + +int getMinNumberFrom(int matrix[3][3], int rows, int cols) { + int min = matrix[0][0]; + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + int currentNumber = matrix[i][j]; + if (currentNumber < min) { + min = currentNumber; + } + } + } + return min; +} + + + +int main() { + + int matrix[3][3] = { + {1, 0, 2}, + {2, 3, 4}, + {4, 5, 4} + }; + int rows = 3, cols = 3; + + printMatrix(matrix, rows, cols); + + int min = getMinNumberFrom(matrix, rows, cols); + int max = getMaxNumberFrom(matrix, rows, cols); + + printf("\nMin Number is %d", min); + printf("\nMax Number is %d", max); + + + return 0; +} \ No newline at end of file From cbabf68e86935aa5c887a72dca6499b70fb5a267 Mon Sep 17 00:00:00 2001 From: Youssef Asaad Date: Wed, 25 Feb 2026 09:23:02 +0300 Subject: [PATCH 20/20] feat(07-l3): 20-palindrome-matrix --- 07-Algorithms-L3/07-Algorithms-L3.vcxproj | 5 +- .../07-Algorithms-L3.vcxproj.filters | 3 ++ 07-Algorithms-L3/20-palindrome-matrix.cpp | 51 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 07-Algorithms-L3/20-palindrome-matrix.cpp diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj b/07-Algorithms-L3/07-Algorithms-L3.vcxproj index 9d705ba..c6cdedc 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj @@ -181,7 +181,10 @@ true - + + true + + diff --git a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters index 4d89690..6826efb 100644 --- a/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters +++ b/07-Algorithms-L3/07-Algorithms-L3.vcxproj.filters @@ -72,5 +72,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/07-Algorithms-L3/20-palindrome-matrix.cpp b/07-Algorithms-L3/20-palindrome-matrix.cpp new file mode 100644 index 0000000..5e857da --- /dev/null +++ b/07-Algorithms-L3/20-palindrome-matrix.cpp @@ -0,0 +1,51 @@ +#include +#include + + +void printMatrix(int matrix[3][3], int rows, int cols) { + printf("The following is a 3*3 random matrix: \n"); + for (int i = 0; i < rows; i++) { + for (int j = 0; j < cols; j++) { + + std::cout << std::setw(3) << matrix[i][j] << "\t"; + } + std::cout << std::endl; + } +} + +bool isPalindromeArray(int arr[3], int length) { + for (int i = 0; i < length /2; i++) { + if (arr[i] != arr[length - 1 - i]) return false; + } + return true; +} + +bool isPalindromeMatrix(int matrix[3][3], int rows, int cols) { + + for (int i = 0; i < rows; i++) { + bool isPalindrome = isPalindromeArray(matrix[i], cols); + if (!isPalindrome) return false; + } + return true; +} + + + +int main() { + + int matrix[3][3] = { + {1, 0, 1}, + {1, 0, 8}, + {1, 0, 1} + }; + int rows = 3, cols = 3; + + printMatrix(matrix, rows, cols); + + bool isPalindrome = isPalindromeMatrix(matrix, rows, cols); + (isPalindrome) ? printf("\nYes, palindrome matrix") : + printf("\nNo, Not a palindrome matrix"); + + + return 0; +} \ No newline at end of file