[C++] Sprawdzenie kodu

0

Witam,
kompiluję ten kod w Dev C++ ale wywala błąd.
Czy mógłby ktoś to sprawdzić i poprawić błąd?

//---------------------------------------------------------------------------
#include <iostream.h>
#include<iostream>
#include<cmath>
#include <conio.h>
#include <math.h>
//#include <iomanip.h>
//---------------------------------------------------------------------------
// Obliczanie funkcji sinus poprez przyblizenie szeregiem potegowym
// sin(xr)= xr/1 - (xr*xr*xr)/(1*2*3) + (xr*xr*xr*xr*xr)/(1*2*3*4*5) - .........
int main()
{
float s, // wartosc funkcji sinus (suma szeregu)
x, // argument funkcji sinus w stopniach
w, // wartosc kolejnego wyrazu szeregu
eps, // dokladnosc obliczen
xr, // argument funkcji sinus w radianach
xr2; // argument w radianach do kwadratu
int i; // liczba iteracji
do{
// clrscr();
cout<<"\n\n======================OPIS PROGRAMU===================================";
cout<<"\n Obliczanie funkcji sinus poprez przyblizenie szeregiem potegowym\n";
cout<<" sin(xr)= xr/1 - (xr*xr*xr)/(1*2*3) + (xr*xr*xr*xr*xr)/(1*2*3*4*5) - ...\n\n";
cout<<"Podaj kat w stopniach i dokladnosc mniejsza od 1: " ;
cin>>x>>eps;

// wprowadz dane: kat w stopniach i dokladnosc (< 1)

xr = (x/180)*M_PI; //zamiana na radiany
xr2 = xr*xr; //uzupelnij
i = 0;
s = xr; w = s;
do
{
i++;
w = w*xr2/((2*i+2)*(2*i+3)); //uzupelnij
if (i%2 != 0) s-=w; else s+=w ; //uzupelnij;
}
while (w<eps );
cout << "\nsin(" << setprecision(5) << x
<< ") = " << setprecision(7)<< s << endl;
cout << "\nliczba iteracji = " << i << endl;
cout << "SIN(xr) z math.h = "<< sin(xr)<<endl;
cout<< "\n ...press any key...(ESC=27 - stop)";
}while( getch()!= 27);
return 0;
}
//---------------------------------------------------------------------------

Kod znaleziony w sieci.

Na dole w oknie wywala, że są dwa błędy - log kompilacji:

Kompilator: Default compiler
Wykonywanie g++.exe...
g++.exe "C:\Dev-Cpp\Programy\fcjasin.cpp" -o "C:\Dev-Cpp\Programy\fcjasin.exe" -I"C:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"C:\Dev-Cpp\include\c++\3.4.2\backward" -I"C:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"C:\Dev-Cpp\include\c++\3.4.2" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,
from C:\Dev-Cpp\Programy\fcjasin.cpp:2:
C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
C:\Dev-Cpp\Programy\fcjasin.cpp: In function int main()': C:\Dev-Cpp\Programy\fcjasin.cpp:41: error: setprecision' undeclared (first use this function)
C:\Dev-Cpp\Programy\fcjasin.cpp:41: error: (Each undeclared identifier is reported only once for each function it appears in.)

Wykonanie zakończone

2 C:\Dev-Cpp\include\c++\3.4.2\backward\iostream.h:31, from C:\Dev-Cpp\Programy\fcjasin.cpp In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, from C:\Dev-Cpp\Programy\fcjasin.cpp

2 C:\Dev-Cpp\Programy\fcjasin.cpp from C:\Dev-Cpp\Programy\fcjasin.cpp

32:2 C:\Dev-Cpp\include\c++\3.4.2\backward\backward_warning.h #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.

C:\Dev-Cpp\Programy\fcjasin.cpp In function `int main()':

41 C:\Dev-Cpp\Programy\fcjasin.cpp `setprecision' undeclared (first use this function)

(Each undeclared identifier is reported only once for each function it appears in.)
</cpp>

0

Kod jest z sieci znaleziony w całości. Już działa. Mam jednak pytane.
Ponieważ wydaj mi się, że jest to kod obliczający wartość sin z szeregu, tak jak jest zresztą napisane.

Miał być to wzór taylora
http://pl.wikipedia.org/wiki/Wz%C3%B3r_Taylora

i reszta
Reszta w postaci Lagrange'a
http://pl.wikipedia.org/wiki/Wz%C3%B3r_Taylora#Reszta_w_postaci_Lagrange.27a

Ale nie wiem czy to właśnie tak liczy tego sin?
Wy jesteście specami od programowanie, może moglibyście pomóc?

1 użytkowników online, w tym zalogowanych: 0, gości: 1