1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| // Лаба1_0.cpp: определяет точку входа для консольного приложения.
//
#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;
int aib(const int a, const int b);
float schag(const float h,const float xk, const float xn);
float xn_xk(const float xn, const float xk);
float Sin(float x, float a);
long fact(int n)
{ if (n<0) return 0;
if (n==0) return 1;
return n*fact(n-1);
}
int _tmain(int argc, _TCHAR* argv[])
{ int a,b;
float x,xn,xk,h,f,max,bf;
printf_s("\n Vvod a,b \n");
scanf_s("%d%d",&a,&b);
aib(a,b);
printf_s("\n Vvod xn,xk \n");
scanf_s("%f%f",&xn,&xk);
xn_xk(xn,xk);
printf_s("\n vvedite shag ");
scanf_s("%f",&h);
schag(h,xn,xk);
x=xn;
max=0;
bf=b;
while (x<xk)
{
f=(((fact(a)-fact(b))*x+(Sin(x,a))) / (fact(b)+2*tan(a*sqrt(bf)))) * cos(3*x);
if (f>max) max=f;
x=x+h;
}
printf_s("\n maximum = %f \n",max);
system("pause");
return 0;
}
int aib(const int a, const int b)
{
if (a<=0 || b<=0)
cout << ("erro");
return 0;
}
float xn_xk(const float xn, const float xk)
{
if (xn>xk)
cout << ("erro");
return 0;
}
float schag(const float h,const float xk, const float xn)
{
if (h<=0)
cout << ("erro");
return 0;
}
float Sin(float x, int a)
{
return sin(fact(a) * x) * sin(fact(a) * x);
}
float Tan(int a, float bf)
{
return tan(a*sqrt(bf));
} |