```/* F07CE_P0W_F C++ Header Example Program.
*
* Copyright 2019 Numerical Algorithms Group.
* Mark 27, 2019.
*/

#include <nag.h>
#include <nagx04.h>
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void)
{
int       exit_status = 0;
Integer   nrhs = 1, ifail = 0;

cout << "F07CE_P0W_F C++ Header Example Program Results\n\n";
// Skip heading in data file
string mystr;
getline (cin, mystr);

// Read problem size and number of right-hand-sides
Integer n;
cin >> n;
cin >> nrhs;

// Allocate arrays containing A and its factorized form, B
// and the solution X.
double  *dl=0, *d=0, *du=0, *du2=0, *x=0;
Integer *ipiv = 0;
Integer n1 = n-1, n2 = n-2;
dl   = new double  [n1];
d    = new double  [n];
du   = new double  [n1];
du2  = new double  [n2];
ipiv = new Integer [n];
x    = new double  [n*nrhs];

// Read the tridiagonal matrix A and right hand side B, register and copy
for (int i = 0; i<n1; i++) {
cin >> du[i];
}
for (int i = 0; i<n; i++) {
cin >> d[i];
}
for (int i = 0; i<n1; i++) {
cin >> dl[i];
}
for (int i = 0; i<n; i++) {
for (int j = 0; j<nrhs; j++) {
int k = i + j*n;
cin >> x[k];
}
}

// Factorize the tridiagonal matrix A
ifail = 0;

// Solve the equations Ax = b for x
ifail = 0;

cout << "\n\n";
NagError  fail;
INIT_FAIL(fail);
x04cac(Nag_ColMajor,Nag_GeneralMatrix,Nag_NonUnitDiag,n,nrhs,x,n,
"  Solution",0,&fail);

delete [] dl;
delete [] d;
delete [] du;
delete [] du2;
delete [] ipiv;
delete [] x;
return exit_status;
}
```