#include <iostream> #include <cmath> #include <fstream> #include <ctime> #include <vector> #define n 3 using namespace std; void GaussianElimination(double **,double *b ,double *y); int main(int argc, char * argv[]) { /* values Row0 = 0, 2, 1; b0= -8 Row1 = 1, -2, -3; b1 = 0 Row3 = -1, 1, 2; b2= 3 Ans = -4, -5, 2 */ //int **A = new {{0.0, 2.0, 1.0, -8.0}, {1.0, -2.0, -3.0, 0.0},{-1.0, 1.0, 2.0,3.0}}; double *A[n]; for (int i=0; i < n; i++) A[i] = new double [n]; double *b = new double[n]; double *y = new double[n]; A[0][0] =0.0;A[0][1] =2.0; A[0][2] = 1.0; //A[0][3] = -8.0; A[1][0] =1.0;A[1][1] =-2.0; A[1][2] =-3.0; //A[1][3] = 0.0; A[2][0] =-1.0;A[0][1] =1.0; A[0][2] = 2.0; //A[0][3] = 3.0; b[0] = -8.0; b[1] = 0.0; b[2] = 3.0; GaussianElimination(A, b ,y); delete [] y; delete [ ]b; for(int i = 0; i < n; i++) delete [] A[i]; delete [ ] A; }
for (int i=0; i < n; i++) A[i] = new double [n];
for(int i = 0; i < n; i++) delete [] A[i];
double *A[n];
double A[n][n];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)