Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Задача 1. Работает как-то не совсем правильно. Ну, или я с проверкой что-то напутал.
- #include <cmath>
- #include <ctime>
- #include <cstdlib>
- #include <cstring>
- #include <string>
- #include <iostream>
- using namespace std;
- double Arctg1(double x, double E,int n){
- int zn, s;
- double sum,res,xx;
- sum=0;
- s=1;
- while (s<=n){
- if((s-1)%2==0) zn=1;
- else zn=-1;
- xx=1;
- for (int i=1;i<=(2*s-2);i++){
- xx*=x;
- }
- res=(zn*xx)/(2*s+1);
- if (abs(res)>E)sum+=res;
- s+=1;
- }
- return sum;
- }
- int main(){
- srand(time(0));
- setlocale(0,"");
- double x,E;
- int n;
- x:
- cout<<"Введите X:"<<endl;
- cin>>x;
- cout<<endl<<"Введите N:"<<endl;
- cin>>n;
- if((abs(x)<1)&&(n>=1)){
- for(int i=1;i<=6;i++){
- cout<<"Введите Эпсилон:"<<endl;
- cin>>E;
- cout<<endl<<"Arctg="<<Arctg1(x,E,n)<<endl<<endl;
- cout<<endl<<"Проверка! Arctg = "<<atan(x)<<endl;
- }
- }
- cout<<endl<<endl<<"Если хотите повторить - введите 1"<<endl;
- cin>>n;
- if (n==1) {system("cls"); /*system("clean");*/ goto x;}
- }
Advertisement
Add Comment
Please, Sign In to add comment