Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo leute, ich habe ein Problem bei einem Programm und zwar:

bei dieser schleife:

while(abs(res2-res)>0.00001)

{

res2=res;

res = (fa(x+h)-fa(x)) / h;

h = h / 10;

}
kommt die Fehlermeldung:
call of overloaded `abs(double)' is ambiguous 

candidates are: int abs(int) 

long long int __gnu_cxx::abs(long long int)

long int std::abs(long int) 
was sich explizit auf
while(abs(res2-res)>0.00001)
bezieht... Wäre dieser blöde Fehler nicht würde alles wunderbar funktionieren manno Hier noch der ganze code...
#include <cstdlib>

#include <iostream>


using namespace std;


double fa(double x);

double fa2(double x);


int main()

{

    cout << "x\tf(x)\tf2(x)" << endl;


    for(double i = -5;i <= 5; i = i + 0.5)

    {

           printf("%.2f\t%.2f\t%lf\n",i,fa(i),fa2(i));

    }


    system("PAUSE");

    return EXIT_SUCCESS;

}


double fa(double x)

{

return x*x;


}


double fa2(double x)

{

double res=0,res2=1,h=0.1;

while(abs(res2-res)>0.00001)

{

res2=res;

res = (fa(x+h)-fa(x)) / h;

h = h / 10;

}

return res;

}

Ich hoffe ihr könnt mir schnell weiterhelfen!

MfG Artery

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.