-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCALC.cpp
228 lines (171 loc) · 3.27 KB
/
CALC.cpp
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// calc.cpp : implementation file
//
#include "stdafx.h"
#include "psx.h"
#include "calc.h"
#include "float.h"
#include "vardlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// calc
calc::calc()
{
}
calc::~calc()
{
}
BEGIN_MESSAGE_MAP(calc, CWnd)
//{{AFX_MSG_MAP(calc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// calc message handlers
void per(double zwert);
void subt(double fx1);
void facu(long fak);
double permut,fx,pi=3.1415926535897932385;
void calc::vfc(long chia, long chib, long chic, long chid)
{
double a,b,c,d,z;
a = (chia + chib + chic + chid);
b = ( pow(((chia * chid) - (chib * chic)),2));
c = (chia + chib);
c = c * (chic + chid);
c = c * (chia + chic);
c = c * (chib + chid);
d = a * b;
chi = d / c;
phi = sqrt((d/c)/a);
z=sqrt(d/c);
per(z);
zwer = prozent*2;
}
void calc::vrt(long en, long ka, int che)
{
double elemen,klas;
CVarDlg vr;
if( che == 0)
{
facu(en), elemen = permut;
ka = en - ka;
facu(ka), klas = permut;
komb = elemen / klas;
}
else
{
komb = pow(en,ka);
}
}
void calc::mnc(long chib, long chic)
{
double a,b,z;
a = pow((chib - chic),2);
b = (chic + chib);
chi = a / b;
z=sqrt(a/b);
per(z);
zwer = prozent*2;
}
void calc::per(double zwert)
{
double qw=fabsl(zwert);
prozent= qw*(0.0000380036+qw*(0.0000488906+qw*0.000005383));
prozent=1+qw*(0.049867347+qw*(0.021141006+qw*(0.0032776263+prozent)));
prozent=0.5*pow(prozent,-16);
if(zwert<0)
{
prozent=1-prozent;
}
}
void calc::tper(double tx, double n)
{
double w1,w2,w3,w4,ww,xx,yy,zz,n1,i,ij,nn1,nn2=1;
if(n/2 != floor(n/2))
{
n=n+1;
}
n1 = n, n = 1, w4 = tx, tx =pow(tx,2);
w1 = n1/(n1+1*tx), w2 = sqrt(1-w1);
nn1 =2*floor(n1/2)-n1+2;
prozent = 1-w2, w3 = w1*w2/2;
for(i = nn1; i < n1; i = i + 2)
{
ij = i;
if(n1 <= i || fabs(2/i*w3)<(0.00001*prozent))
{
goto e;
}
prozent = prozent-2/i*w3, w3 = w3*w1*(nn2/i+1);
}
e:
prozent = prozent/2, n = n1, tx = w4;
if(tx < 0)
{
prozent = 1-prozent;
}
xx = prozent, yy = -5;
if(xx == 0)
{
goto g;
}
fx = (fabs(xx)), fx = log10(fx), yy = fx + yy;
subt(fx);
zz = fx, fx = yy;
subt(fx);
yy = zz-fx-1;
if(yy >= 19)
{
goto g;
}
if(yy < 0)
{
xx = 0;
goto g;
}
if(zz >= 90)
{
xx = 1e-20,fx = zz, zz = zz-20;
}
ww = fabs(xx*pow(10,-zz )), ww = floor(ww*pow(10,yy)+0.5);
ww = ww*(pow(10,zz))*(pow(10,-yy));
if(fx >= 90)
{
ww = 1e20;
}
if(xx >= 0)
{
xx = ww;
}
else
{
xx = ww * -1;
}
g:
prozent = xx;
}
void subt(double fx1)
{
if(fx1 >= 0)
{
fx1 = floor(fx1);
}
else
{
fx1 = -1*(floor(fabs(fx1)));
}
fx = fx1;
}
void facu(long fak)
{
permut = 1;
do
{
permut = permut * fak;
fak --;
}
while(fak != 1);
}