sqrt absturz



  • //---------------------------------------------------------------------------
    #include <vcl.h>
    #pragma hdrstop
    #include <iostream>
    #include <math>
    #include <conio>
    #include <iomanip>
    #include <stdio>
    using namespace std;
    #pragma argsused
    //-----------------------------Funzionen-------------------------------------
    void Fall1 ( double a,double b,double c,double zwisch1 )
    {
    double zwisch2;
    zwisch1 = sqrt(zwisch1);
    zwisch2 = zwisch1;
    zwisch1 = ( b * -1 ) + zwisch1;
    zwisch2 = ( b * -1 ) - zwisch2;
    zwisch1 = zwisch1 / ( 2 * a );
    zwisch2 = zwisch2 / ( 2 * a );
    cout << " x1 = "<<zwisch1;
    cout << "\n x2 = "<<zwisch2;
    cout << "\n N1 ( "<<zwisch1<<" / 0)";
    cout << "\n N2 ( "<<zwisch2<<" / 0)";
    getch ();
    return;
    }
    
    float Fall2 ( float a,float b,float c,float zwisch1 )
    {
    float zwisch2;
    
    return 0;
    }
    
    //---------------------------------------------------------------------------
    
    int main(int argc, char* argv[])
    {
    cout << fixed << setprecision(3);
    float b = 0;
    float a = 1;
    float c = 0;
    float zwisch1 = 0;
    float zwisch2 = 0;
    cin >> a;
    //if ( a == 0 ){cout << "Vergiss es!"; getch(); return 0; }
    cin >> b;
    cin >> c;
    zwisch1 = 4 * a * c;
    zwisch2 = pow(b,2);
    zwisch1 = zwisch2 - zwisch1;
    if ( zwisch1 < 0)
    {
    cout << "\nZwei Schnittpunkte mit der X-Achse\n";
    Fall1(a, b, c, zwisch1);
    }
    if ( zwisch1 == 0)
    {
    cout << "\n ... in bau...  \n";
    getch();
    return 0;
    Fall2(a, b, c, zwisch1);
    }
    if ( zwisch1 > 0 )
    {
    cout << "\nKein Schnittpunkt mit der X-Achse\n";
    getch();
    cout << "Ende...";
    getch();
    return 0;
    }
    getch();
    return 0;
    }
    
    //---------------------------------------------------------------------------
    

    er stürtzt ab wenn er die quadratwurzel errechnen soll. als testwerte sind 1 1 1 ganz gut ^^.

    fehlermeldung in der konsole ist domain error oO.

    kann mir jemand bitte weiterhelfen. ich find den fehler nicht

    hier gehts übrigens um die mitternachtsformel



  • also wenn du ".h" nennst gehts bei mir irgendwie 😉



  • Stichwort: Debugger

    (blind geraten: Du berechnest irgendwo die Wurzel aus einer negativen Zahl)



  • danke stoll 🙂 ich bin so dumm ^^ durch deinen kommentar hab ich hier grad mal schnell was nachgerechnet ! aber vielen dank für den hinweiß !



  • hinweiß

    Hinweis 😉

    weiß (Farbe oder von wissen)



  • Erhard Henkes schrieb:

    hinweiß

    Hinweis 😉

    weiß (Farbe oder von wissen)

    Ich weiß, Weiß weiß nichts. :xmas1:


Anmelden zum Antworten