/////////////////////////////////////////////////////////// // Softwarebauelemente I, Aufgabe M1.2 // // author: Stephan Brumme // last changes: October 14, 2000 // include I/O-streams #include // read all coefficients int Read(double **arCoefficients) { // store max. exponent int nMaxExponent; // get max. exponent cout<<"Hoechste Potenz: "; cin>>nMaxExponent; // allocate some memory on the heap *arCoefficients = new double[nMaxExponent+1]; // read all coefficients for (int nLoop=nMaxExponent; nLoop>=0; nLoop--) { cout<<"a"<>(*arCoefficients)[nLoop]; } // return max. exponent return nMaxExponent; } // calculate correspending Y-value for a given X using Horner formula double Horner(double dX, int nMaxExponent, double *arCoefficients) { // result, initialize it double dResult = 0.0; // go thru the whole array and perform Horner for (int nLoop = nMaxExponent; nLoop>=0; nLoop--) { // dResult_new = dResult_old * dX dResult *= dX; // dResult_new = dResult_old * dX + arCoefficients[nLoop] dResult += arCoefficients[nLoop]; } // return result return dResult; } // main function void main() { // store coefficients double *arCoefficients; // get max exponent int nMaxExponent = Read(&arCoefficients); // the X value double dX; // get X cout<<"An welcher Stelle soll der Funktionswert berechnet werden: "; cin>>dX; // calculate and print Y (using Horner) cout<<"f("<