Scope problem in my program on C++ in visual studio

  Kiến thức lập trình

Please tell me how to fix the error of not defining Sn in lines where division occurs. I tried different ways to fix it, but it didn’t work. I tried to use a breakpoint, but the compiler detects the error before it even starts moving through the code. As far as I understand, since the breakpoint is not working. Then I tried to use the flag, but that didn’t work either. The full code is in the link below.

code: https://onlinegdb.com/FkqMG5yqu
input: https://onlinegdb.com/BXFCDDVYb

if (numos > 0)
{
    cout << "Displacements and stresses at specified points in the bodyn";
    //cout FMT "point" FMT "x coord" FMT "y coord" FMT "u" FMT "uy" FMT "sigxx" FMT "sigyy" FMT "sigxy" << 'n';
    cout FMT "point" FMT "x coord" FMT "y coord" FMT "sigxx" FMT "sigyy" << 'n';

    int npoint = 0;
    for (int n = 1; n <= numos; n++)
    {
        in >> xbeg >> ybeg >> xend >> yend >> numpb;

        int nump = numpb + 1;
        double delx = (xend - xbeg) / nump;
        double dely = (yend - ybeg) / nump;
        if (numpb > 0) nump++;
        if (delx * delx + dely * dely == 0.0) nump = 1;

        for (int ni = 1; ni <= nump; ni++)
        {
            bool flag = false;
            double xp = xbeg + (ni - 1) * delx;
            double yp = ybeg + (ni - 1) * dely;

            Point U;
            Stress Sig = Pf;
            bool ok = true;
            for (int j = 1; j <= numbe; j++)
            {
                int jn = 2 * j;
                int js = jn - 1;
                double xj = xm[j], yj = ym[j], aj = a[j];
                double cosbj = cosbet[j], sinbj = sinbet[j];
                if (sqrt((xp - xj) * (xp - xj) + (yp - yj) * (yp - yj)) < 2 * aj)
                {
                    ok = false;
                    break;
                }

                Point Us, Un;
                Stress Ss, Sn;
                flag = true;
                coeff(xp, yp, xj, yj, aj, cosbj, sinbj, +1, T, Ss, Sn, Us, Un);
                switch (ksym)
                {
                case 1:
                    break;
                case 2:
                    xj = 2 * xsym - xm[j];
                    coeff(xp, yp, xj, yj, aj, cosbj, -sinbj, -1, T, Ss, Sn, Us, Un);
                    break;
                case 3:
                    yj = 2 * ysym - ym[j];
                    coeff(xp, yp, xj, yj, aj, -cosbj, sinbj, -1, T, Ss, Sn, Us, Un);
                    break;
                case 4:
                    xj = 2 * xsym - xm[j];
                    coeff(xp, yp, xj, yj, aj, cosbj, -sinbj, -1, T, Ss, Sn, Us, Un);
                    xj = xm[j];
                    yj = 2 * ysym - ym[j];
                    coeff(xp, yp, xj, yj, aj, -cosbj, sinbj, -1, T, Ss, Sn, Us, Un);
                    xj = 2 * xsym - xm[j];
                    coeff(xp, yp, xj, yj, aj, -cosbj, -sinbj, +1, T, Ss, Sn, Us, Un);
                    break;
                }
                U = U + p[js] * Us + p[jn] * Un;
                Sig = Sig + p[js] * Ss + p[jn] * Sn;
            }

            if (ok)
            {
                npoint++;
                double sigxxsign;
                double sigyysign;
                if (flag==true) {
                    sigxxsign = -Sig.xx / Sn.xx;//‘Sn’ was not declared in this scope
                    sigyysign = -Sig.yy / Sn.yy;//‘Sn’ was not declared in this scope
                }
                else {
                    sigxxsign = 100;
                    sigyysign = 100;
                }
                //cout FMT npoint FMT xp FMT yp FMT U.x FMT U.y FMT Sig.xx FMT Sig.yy FMT Sig.xy << 'n';
                cout FMT npoint FMT xp FMT yp FMT sigxxsign FMT sigyysign << 'n';
            }
        }
    }
}

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT