Stop working when running : <p>i wrote this code for my university project but it stop working when i try to run it.
can any one please help me where the problem is?
i guess its the pointers but i dont know where its wrong
for t and z if u want to try it use 20 and 5
and when i enter them it stop working instead of giving me outputs
it should give 2 .txt file including some numbers</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;fstream&gt;
using namespace std;

int main()
{
    int t;
    int z;
    double deltaz;
    double deltat;
    double beta;
    double mv=0;

    ofstream out1("Time-setllment.txt");
    ofstream out2("isochrones.txt");

    cout&lt;&lt;"Enter time step(&gt;9&amp;integer only):";
    cin&gt;&gt;t;
    cout&lt;&lt;endl&lt;&lt;"Enter height step(integer only):";
    cin&gt;&gt;z;
    cout&lt;&lt;endl;
    double **u = new double * [z+1];
    for (int i=0;i&lt;z;i++)
        u[i]=new double [t+1];
    double *s = new double [t+1];
    mv = (0.00000003*365*24*3600)/(2*10);
    deltaz = 20/z;
    deltat = 50/t;
    beta = (2*deltat)/(deltaz*deltaz);
    if (beta&gt;0.5)
        cout&lt;&lt;"Beta is more than 0.5 :|"&lt;&lt;endl;
    else
    {
    for (int i=0;i&lt;z+1;i++)
    {
        if (i==0 || i==z)
        {
            for (int j=0;j&lt;t+1;j++)
                u[i][j] = 0;
        }
        else
        {
            u[i][0]=70-3.5*(i*deltaz);
        }
    }
    for (int j=1;j&lt;t;j++)
    {
        for (int i=1;i&lt;z;i++)
        {
            u[i][j] = u[i][j-1]+beta*(u[i-1][j-1]+u[i+1][j-1]-2*u[i][j-1]);
        }
    }
    for (int j=1;j&lt;t+1;j++)
    {
        double sigmau=0;
        for (int i=1;i&lt;z;i++)
        {
            sigmau +=u[i][j];
        }
        s[j]=mv*(35*20-deltaz*((u[0][j]+u[z][j])/2+sigmau));
    }


    out1&lt;&lt;"Time \t Settlment \n";
    for (int j=1;j&lt;t+1;j++)
    {
        out1&lt;&lt;j*deltat&lt;&lt;"\t"&lt;&lt;s[j]&lt;&lt;"\n";
    }
    out2&lt;&lt;"Depth \t";
    for (int j=0;j&lt;t+1;j++)
    {
        out2&lt;&lt;"t(year)="&lt;&lt;j*deltat&lt;&lt;"\t";
    }
    out2&lt;&lt;"\n";
    for (int i=0;i&lt;z+1;i++)
    {
        out2&lt;&lt;i*deltaz&lt;&lt;"\t";
        for (int j=0;j&lt;t+1;j++)
        {
            out2&lt;&lt;u[i][j]&lt;&lt;"\t";
        }
    }
    for (int i=0;i&lt;z+1;i++)
        delete []u[i];
    delete []u;
    delete []s;
    }

    return 0;
}
</code></pre>
