Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by ab ( 15 years ago )
#include <QtCore/QCoreApplication>
#include <iostream>
using namespace std;

// Uebergabewerte: Koeffizienten, x-Wert und Groesse des Arrays
double horner(double coefficient[], double x, int n)
{
    double result;
    result = coefficient[n];

    for (int i = n-1; i >=0; i--)
    {
        result = result * x + coefficient[i];
    }

    return result;
}


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    double coeff[] = {3.0,-1.0,0.0,3.0,-1.0,2.0};
    double x = 1.0;

    cout << horner(coeff, x, sizeof(coeff)/sizeof(coeff[0]));

    return a.exec&#40;&#41;;
}

 

Revise this Paste

Your Name: Code Language: