From 4b25222d430a3be8b2072cd671df7513412c8a5c Mon Sep 17 00:00:00 2001 From: Krishna Vedala Date: Tue, 26 May 2020 09:32:37 -0400 Subject: [PATCH] fixed windows build error --- .../gaussian_elimination.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/computer_oriented_statistical_methods/gaussian_elimination.cpp b/computer_oriented_statistical_methods/gaussian_elimination.cpp index ecfbfacc9..0b8bb693d 100644 --- a/computer_oriented_statistical_methods/gaussian_elimination.cpp +++ b/computer_oriented_statistical_methods/gaussian_elimination.cpp @@ -6,7 +6,11 @@ int main() { std::cout << "Matrix size: "; std::cin >> mat_size; - double mat[mat_size + 1][mat_size + 1], x[mat_size][mat_size + 1]; + double **mat = new double *[mat_size + 1], **x = new double *[mat_size]; + for (i = 0; i <= mat_size; i++) { + mat[i] = new double[mat_size + 1]; + if (i < mat_size) x[i] = new double[mat_size + 1]; + } std::cout << std::endl << "Enter value of the matrix: " << std::endl; for (i = 0; i < mat_size; i++) { @@ -49,5 +53,13 @@ int main() { std::cout << "x" << i << "= " << x[i][i] << std::endl; } + + for (i = 0; i <= mat_size; i++) { + delete[] mat[i]; + if (i < mat_size) delete[] x[i]; + } + delete[] mat; + delete[] x; + return 0; }