Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int f_1()
- {
- int n, m, sum = 0;
- cin>>n>>m;
- for(int i = 5; i < n; i += 5)
- {
- if(i % m != 0)
- sum += i;
- }
- return sum;
- }
- int f_2()
- {
- int a, pr = 1;
- cin>>a;
- if(a >= 0)
- {
- for(int i = 2; i <= 8; i += 2)
- {
- pr *= i * i;
- }
- pr -= a;
- }
- else
- {
- for(int i = 3; i <= 9; i += 3)
- {
- pr *= (i - 2);
- }
- }
- return pr;
- }
- int n;
- long double abs_f(long double a)
- {
- if(a > 0)
- {
- return a;
- }
- if(a <= 0)
- {
- return -a;
- }
- }
- long double s_f(long double x)
- {
- long double sum = - 2 * x * x;
- n = 0;
- long double last = sum;
- while(abs_f(sum - (sum + (-2 * x * x / (n * (2 * n - 1)) * last))) > 0.0000001)
- {
- n++;
- sum += -2 * x * x / (n * (2 * n - 1)) * last;
- last = -2 * x * x / (n * (2 * n - 1)) * last;
- }
- return sum;
- }
- long double y_f(long double x)
- {
- return cos(2 * x) - 1;
- }
- int f_3()
- {
- cout<<"Введите точность"<<endl;
- int akk;
- cin>>akk;
- for(long double i = 0.; i <= 1; i += 0.2)
- {
- //cout.width(15);
- cout.precision(akk);
- cout<<i<<' '<<y_f(i)<<' '<<s_f(i)<<' '<<n<<endl;
- }
- }
- double f_4(int n, double x)
- {
- if(n == 0)
- return 1;
- else
- return f_4(n - 1, x) * x * x / (2 * n * (2 * n - 1)) + f_4(n - 1, x);
- }
- main()
- {
- system(" chcp 1251 > nul");
- cout<<"Bведите номер задачи, которую необходимо решить"<<endl;
- int a;
- cin>>a;
- if(a == 1)
- {
- char flag = 'y';
- while(flag == 'y')
- {
- cout<<f_1();
- cout<<endl<<"Продолжить работу?(y/n)"<<endl;
- cin>>flag;
- }
- }
- if(a == 2)
- {
- cout<<f_2();
- }
- if(a == 3)
- {
- f_3();
- }
- if(a == 4)
- {
- int n;
- double x;
- char flag = 'y';
- while(flag == 'y')
- {
- cin>>n>>x;
- cout<<f_4(n, x)<<endl;
- cout<<f_4(3, x)<<endl;
- cout<<f_4(5, x)<<endl;
- cout<<f_4(10, x)<<endl;
- cout<<endl<<"Продолжить работу?(y/n)"<<endl;
- cin>>flag;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement