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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
| #pragma once
namespace Maryin_Andrew_1_0 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
///
/// WARNING: If you change the name of this class, you will need to change the
/// 'Resource File Name' property for the managed resource compiler tool
/// associated with all .resx files this class depends on. Otherwise,
/// the designers will not be able to interact properly with localized
/// resources associated with this form.
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::TextBox^ X;
private: System::Windows::Forms::TextBox^ Y;
private: System::Windows::Forms::TextBox^ N;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::GroupBox^ groupBox1;
private: System::Windows::Forms::TextBox^ results;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ point_place;
private: System::Windows::Forms::TextBox^ log_error;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::PictureBox^ graphick;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->X = (gcnew System::Windows::Forms::TextBox());
this->Y = (gcnew System::Windows::Forms::TextBox());
this->N = (gcnew System::Windows::Forms::TextBox());
this->button1 = (gcnew System::Windows::Forms::Button());
this->groupBox1 = (gcnew System::Windows::Forms::GroupBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->results = (gcnew System::Windows::Forms::TextBox());
this->log_error = (gcnew System::Windows::Forms::TextBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->point_place = (gcnew System::Windows::Forms::TextBox());
this->graphick = (gcnew System::Windows::Forms::PictureBox());
this->groupBox1->SuspendLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->graphick))->BeginInit();
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(47, 58);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(77, 13);
this->label1->TabIndex = 0;
this->label1->Text = L"Координата Х";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(47, 84);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(77, 13);
this->label2->TabIndex = 1;
this->label2->Text = L"Координата Y";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(109, 110);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(15, 13);
this->label3->TabIndex = 2;
this->label3->Text = L"N";
//
// X
//
this->X->Location = System::Drawing::Point(130, 55);
this->X->Name = L"X";
this->X->Size = System::Drawing::Size(100, 20);
this->X->TabIndex = 3;
//
// Y
//
this->Y->Location = System::Drawing::Point(130, 81);
this->Y->Name = L"Y";
this->Y->Size = System::Drawing::Size(100, 20);
this->Y->TabIndex = 4;
this->Y->TextChanged += gcnew System::EventHandler(this, &Form1::textBox2_TextChanged);
//
// N
//
this->N->Location = System::Drawing::Point(130, 107);
this->N->Name = L"N";
this->N->Size = System::Drawing::Size(100, 20);
this->N->TabIndex = 5;
//
// button1
//
this->button1->Location = System::Drawing::Point(50, 133);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(180, 23);
this->button1->TabIndex = 6;
this->button1->Text = L"Посчитать результаты";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// groupBox1
//
this->groupBox1->Controls->Add(this->label6);
this->groupBox1->Controls->Add(this->results);
this->groupBox1->Controls->Add(this->log_error);
this->groupBox1->Controls->Add(this->label5);
this->groupBox1->Controls->Add(this->label4);
this->groupBox1->Controls->Add(this->point_place);
this->groupBox1->Location = System::Drawing::Point(50, 188);
this->groupBox1->Name = L"groupBox1";
this->groupBox1->Size = System::Drawing::Size(396, 298);
this->groupBox1->TabIndex = 7;
this->groupBox1->TabStop = false;
this->groupBox1->Text = L"Результаты";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(7, 182);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(50, 13);
this->label6->TabIndex = 9;
this->label6->Text = L"Ошибки:";
//
// results
//
this->results->Location = System::Drawing::Point(10, 102);
this->results->Name = L"results";
this->results->Size = System::Drawing::Size(380, 20);
this->results->TabIndex = 3;
//
// log_error
//
this->log_error->Location = System::Drawing::Point(6, 198);
this->log_error->Multiline = true;
this->log_error->Name = L"log_error";
this->log_error->Size = System::Drawing::Size(384, 94);
this->log_error->TabIndex = 8;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(7, 86);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(123, 13);
this->label5->TabIndex = 2;
this->label5->Text = L"Результат вычислений";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(7, 25);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(113, 13);
this->label4->TabIndex = 1;
this->label4->Text = L"Расположение точки";
//
// point_place
//
this->point_place->Location = System::Drawing::Point(10, 41);
this->point_place->Name = L"point_place";
this->point_place->Size = System::Drawing::Size(380, 20);
this->point_place->TabIndex = 0;
//
// graphick
//
this->graphick->InitialImage = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"graphick.InitialImage")));
this->graphick->Location = System::Drawing::Point(452, 12);
this->graphick->Name = L"graphick";
this->graphick->Size = System::Drawing::Size(539, 521);
this->graphick->TabIndex = 8;
this->graphick->TabStop = false;
this->graphick->WaitOnLoad = true;
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(1003, 545);
this->Controls->Add(this->graphick);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->button1);
this->Controls->Add(this->N);
this->Controls->Add(this->Y);
this->Controls->Add(this->X);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->groupBox1->ResumeLayout(false);
this->groupBox1->PerformLayout();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^ >(this->graphick))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void textBox2_TextChanged(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
//Выполняем все действия по нажатию на кнопочку.
int n;
float R2=3.2,R1=27.4,x,y,Y_=-20.5;
bool type_of_data = true;
/*if(strcmp(N->Text,'')) {log_error->Text+="Вы не ввели n\n"; type_of_data=false; }
if(strcmp(X->Text,'')) {log_error->Text+="Вы не ввели x\n"; type_of_data=false; }
if(strcmp(Y->Text,'')) {log_error->Text+="Вы не ввели y\n"; type_of_data=false; } */
if(type_of_data==true) {
n = Convert::ToInt16(N->Text);
x=Convert::ToDouble(X->Text);
y=Convert::ToDouble(Y->Text);
if(x*x+y*y<R2*R2) {
point_place->Text="Точка находится вне фигуры (внутри круга)!";
results->Text=Convert::ToString(R2-R1);
//точка в центральном круге.
}else {
//точка вне круга
if(y>=0) {
point_place->Text="Точка выше оси Х и находится вне фигуры";
results->Text=Convert::ToString(R2-R1);
//точка над фигурой
if(x*x+y*y<=R1*R1) {
point_place->Text="Точка выше оси Х и находится в фигуре";
//точка в фигуре сверху
if(x>=0) {
//A1
results->Text=Convert::ToString(function_A1(x,y,n));
} else {
//A2
results->Text=Convert::ToString(function_A2(x,y,n,R1));
}
}
} else {
point_place->Text="Точка ниже оси Х и находится вне фигуры";
results->Text=Convert::ToString(R2-R1);
if(y>=Y_ && x<=abs(R1)) {
point_place->Text="Tочка ниже оси Х и находится в фигуре";
if(x>=0) {
//A1
results->Text=Convert::ToString(function_A1(x,y,n));
} else {
//A2
results->Text=Convert::ToString(function_A2(x,y,n,R1));
}
} else {
point_place->Text="Точка ниже оси Х и находится слева или справа от фигуры";
results->Text=Convert::ToString(R2-R1);
}
}
}
}
}
int abs(int n) {
if(n<0) return -n; else return n;
//Написал свой abs, чтобы опробывать работу, но свой log и cos писать влом.
}
double function_A1(double x,double y,double n) {
return 1;
//return (-x*(1-x*y-(x*x/y)))/(1+x*x/y - log(x)+cos(x/y) + x) + fibon(n);
}
double function_A2(double x,double y,double n,double R) {
//Не работают функции abs, cos и др. Если вставить в cpp файл пользовательские функции, то они тоже перестанут работать.
//return ((R+7.39)*x*0.001)/pow(x,pow(5,1.4/y-1))+(-x*(1-x*y+x*x/y)/(1+x*x/y-log(x)+cos(x/y)+x)) + factorial_(n);
return 2;
}
};
} |