Форум программистов, компьютерный форум, киберфорум
C++/CLI Windows Forms
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.71/7: Рейтинг темы: голосов - 7, средняя оценка - 4.71
0 / 0 / 0
Регистрация: 18.11.2017
Сообщений: 2
1

Как исправить warning C4700: использована неинициализированная локальная переменная "M_PI"

18.11.2017, 11:02. Показов 1288. Ответов 7
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Строка 316 и 339
C++
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
341
342
343
344
345
346
347
348
#pragma once
#include<cmath>
#include<stdlib.h>
#include<time.h>
#define _use_math_defines
#include<math.h>
 
namespace Project2 {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms::DataVisualization::Charting;;
    using namespace System::Data;
    using namespace System::Drawing;
 
    /// <summary>
    /// Сводка для MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::DataVisualization::Charting::Chart^  chart1;
    protected:
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::TextBox^  textBox5;
    private: System::Windows::Forms::Label^  label1;
 
 
 
 
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::Button^  button3;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::Label^  label5;
 
    private:
        /// <summary>
        /// Обязательная переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Требуемый метод для поддержки конструктора — не изменяйте 
        /// содержимое этого метода с помощью редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            System::Windows::Forms::DataVisualization::Charting::ChartArea^  chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
            System::Windows::Forms::DataVisualization::Charting::Legend^  legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
            System::Windows::Forms::DataVisualization::Charting::Series^  series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series2 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series3 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series4 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series5 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->label5 = (gcnew System::Windows::Forms::Label());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->BeginInit();
            this->SuspendLayout();
            // 
            // chart1
            // 
            chartArea1->Name = L"ChartArea1";
            this->chart1->ChartAreas->Add(chartArea1);
            legend1->Name = L"Legend1";
            this->chart1->Legends->Add(legend1);
            this->chart1->Location = System::Drawing::Point(0, -1);
            this->chart1->Name = L"chart1";
            series1->ChartArea = L"ChartArea1";
            series1->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
            series1->Color = System::Drawing::Color::Black;
            series1->Legend = L"Legend1";
            series1->Name = L"Series1";
            series2->ChartArea = L"ChartArea1";
            series2->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
            series2->Color = System::Drawing::Color::Black;
            series2->Legend = L"Legend1";
            series2->Name = L"Series2";
            series3->ChartArea = L"ChartArea1";
            series3->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
            series3->Color = System::Drawing::Color::Black;
            series3->Legend = L"Legend1";
            series3->Name = L"Series3";
            series4->ChartArea = L"ChartArea1";
            series4->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Point;
            series4->Color = System::Drawing::Color::Blue;
            series4->Legend = L"Legend1";
            series4->Name = L"Series4";
            series5->ChartArea = L"ChartArea1";
            series5->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Point;
            series5->Color = System::Drawing::Color::Blue;
            series5->Legend = L"Legend1";
            series5->Name = L"Series5";
            this->chart1->Series->Add(series1);
            this->chart1->Series->Add(series2);
            this->chart1->Series->Add(series3);
            this->chart1->Series->Add(series4);
            this->chart1->Series->Add(series5);
            this->chart1->Size = System::Drawing::Size(460, 214);
            this->chart1->TabIndex = 0;
            this->chart1->Text = L"chart1";
            // 
            // textBox1
            // 
            this->textBox1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox1->Location = System::Drawing::Point(200, 226);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(45, 20);
            this->textBox1->TabIndex = 1;
            this->textBox1->Text = L"10000";
            // 
            // textBox2
            // 
            this->textBox2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox2->Location = System::Drawing::Point(92, 287);
            this->textBox2->Name = L"textBox2";
            this->textBox2->ReadOnly = true;
            this->textBox2->Size = System::Drawing::Size(85, 20);
            this->textBox2->TabIndex = 2;
            // 
            // textBox3
            // 
            this->textBox3->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox3->Location = System::Drawing::Point(92, 319);
            this->textBox3->Name = L"textBox3";
            this->textBox3->ReadOnly = true;
            this->textBox3->Size = System::Drawing::Size(85, 20);
            this->textBox3->TabIndex = 3;
            // 
            // textBox4
            // 
            this->textBox4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox4->Location = System::Drawing::Point(336, 282);
            this->textBox4->Name = L"textBox4";
            this->textBox4->ReadOnly = true;
            this->textBox4->Size = System::Drawing::Size(97, 20);
            this->textBox4->TabIndex = 4;
            // 
            // textBox5
            // 
            this->textBox5->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox5->Location = System::Drawing::Point(336, 320);
            this->textBox5->Name = L"textBox5";
            this->textBox5->ReadOnly = true;
            this->textBox5->Size = System::Drawing::Size(97, 20);
            this->textBox5->TabIndex = 5;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(90, 226);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(87, 13);
            this->label1->TabIndex = 6;
            this->label1->Text = L"Сколько точек\?";
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(24, 363);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(101, 37);
            this->button1->TabIndex = 11;
            this->button1->Text = L"Фигура";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(180, 363);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(97, 37);
            this->button2->TabIndex = 12;
            this->button2->Text = L"Расчет";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(336, 363);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(88, 37);
            this->button3->TabIndex = 13;
            this->button3->Text = L"Выход";
            this->button3->UseVisualStyleBackColor = true;
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(3, 289);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(74, 13);
            this->label2->TabIndex = 14;
            this->label2->Text = L"Точек внутри";
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(3, 319);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(83, 13);
            this->label3->TabIndex = 15;
            this->label3->Text = L"Точек снаружи";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(225, 282);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(95, 13);
            this->label4->TabIndex = 16;
            this->label4->Text = L"Площадь фигуры";
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(234, 319);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(86, 13);
            this->label5->TabIndex = 17;
            this->label5->Text = L"Погрешность %";
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(462, 406);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->chart1);
            this->Name = L"MyForm";
            this->Text = L"MyForm";
            this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->EndInit();
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
 
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    Series^plot1 = chart1->Series[0];
    Series^plot2 = chart1->Series[1];
    Series^plot3 = chart1->Series[2];
    double y, x;
    for (int i = -100; i <= 100; i++)
    {
        x = i;
        y = sqrt(10000 - x*x);
        plot1->Points->AddXY(x, y);
    }
    for (int i = -100; i <= 100; i++)
    {
        x = i;
        y = -0.5*(x + 100);
        plot2->Points->AddXY(x, y);
    }
    for (int i = -100; i <= 0; i++)
    {
        x = 100;
        y = i;
        plot3->Points->AddXY(x, y);
    }
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
    Series^plot4 = chart1->Series[3];
    Series^plot5 = chart1->Series[4];
    int T_vn, T_za, n;
    float x, y, S_fig, S_r, er, M_PI;
    plot4->Points->Clear();
    plot5->Points->Clear();
    if (textBox1->Text != "")
    {
        n = Convert::ToInt32(textBox1->Text);
        T_vn = 0; T_za = 0;
        for (int i = 1; 1 <= n; i++)
        {
            x = rand() % 201 - 100;
            y = rand() % 201 - 100;
        }
        if (((x*x + y*y <= 10000) && (y >= 0)) || ((y<0) && (x <= 100) && (y >= -0.5*(x + 100))))
        {
            plot4->Points->AddXY(x, y); T_vn++;
        }
        else
        {
            plot5->Points->AddXY(x, y); T_za++;
        }
        textBox2->Text = Convert::ToString(T_vn);
        textBox3->Text = Convert::ToString(T_za);
        S_fig = 40000 * T_vn / n;
        S_r = 10000 + M_PI * 10000 / 2;
        er = fabs(S_r - S_fig) / S_r * 100;
        textBox4->Text = Convert::ToString(S_fig);
        textBox5->Text = Convert::ToString(er);
    }
}
private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
}
};
}
Вылазит ошибка \users\daymo\desktop\project2\project2\myform.h(339): warning C4700: использована неинициализированная локальная переменная "M_PI"
Ошибка в строке 339
Как исправить подскажите пожалуйста)
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
18.11.2017, 11:02
Ответы с готовыми решениями:

Ошибка: использована неинициализированная локальная переменная "a"
private: System::Void button1_Click_2(System::Object^ sender, System::EventArgs^ e) { ...

Как исправить: warning C4700: использована неинициализированная локальная переменная "a"?
Задача: Код:#include &lt;iostream&gt; #include &lt;ctime&gt; using namespace std; #define M 10 #define...

Warning C4700: использована неинициализированная локальная переменная
1&gt;c:\users\артем\documents\visual studio 2012\projects\consoleapplication37\source.cpp(7): warning...

Warning C4700: использована неинициализированная локальная переменная
Я прекрасно понимаю что это значит но проблема в том что я сначала прогу написал в мэйне, а потом...

7
7792 / 6559 / 2984
Регистрация: 14.04.2014
Сообщений: 28,668
18.11.2017, 11:13 2
В 5-й строке большими буквами напиши это название.
0
Заклинатель змей
700 / 555 / 219
Регистрация: 30.04.2016
Сообщений: 2,591
18.11.2017, 11:13 3
Renounced, чтение документации от Microsoft нынче моветон? https://msdn.microsoft.com/ru-... aceh6.aspx
C++
1
2
#define _USE_MATH_DEFINES // for C++  
#include <cmath>
1
SlavaSokolov
18.11.2017, 11:14
  #4

Не по теме:

Инициализируйте переменную.

0
7792 / 6559 / 2984
Регистрация: 14.04.2014
Сообщений: 28,668
18.11.2017, 11:15 5
SlavaSokolov, это константа для числа пи.
0
1494 / 1209 / 821
Регистрация: 29.02.2016
Сообщений: 3,614
18.11.2017, 11:15 6
C++
1
2
3
4
5
6
7
8
9
10
#define _USE_MATH_DEFINES
 
#include <cmath>
#include <iostream>
using namespace std;
 
int main() { 
  std::cout << M_PI << " " << M_E << " " << M_SQRT2 << endl;
  return 0;
}
0
0 / 0 / 0
Регистрация: 18.11.2017
Сообщений: 2
18.11.2017, 11:20  [ТС] 7
Всем спасибо помогло)

И можно еще 1 вопрос теперь такие ошибки как их решить?
1>c:\users\daymo\desktop\project2\project2\MyForm.h(327): warning C4244: =: преобразование "int" в "float", возможна потеря данных
1>c:\users\daymo\desktop\project2\project2\MyForm.h(328): warning C4244: =: преобразование "int" в "float", возможна потеря данных
1>c:\users\daymo\desktop\project2\project2\MyForm.h(340): warning C4244: =: преобразование "int" в "float", возможна потеря данных


C++
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
341
342
343
344
345
346
347
348
349
350
#pragma once
#include<cmath>
#include<stdlib.h>
#include<time.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <Windows.h>
 
namespace Project2 {
 
    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms::DataVisualization::Charting;;
    using namespace System::Data;
    using namespace System::Drawing;
 
    /// <summary>
    /// Сводка для MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: добавьте код конструктора
            //
        }
 
    protected:
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        ~MyForm()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::DataVisualization::Charting::Chart^  chart1;
    protected:
    private: System::Windows::Forms::TextBox^  textBox1;
    private: System::Windows::Forms::TextBox^  textBox2;
    private: System::Windows::Forms::TextBox^  textBox3;
    private: System::Windows::Forms::TextBox^  textBox4;
    private: System::Windows::Forms::TextBox^  textBox5;
    private: System::Windows::Forms::Label^  label1;
 
 
 
 
    private: System::Windows::Forms::Button^  button1;
    private: System::Windows::Forms::Button^  button2;
    private: System::Windows::Forms::Button^  button3;
    private: System::Windows::Forms::Label^  label2;
    private: System::Windows::Forms::Label^  label3;
    private: System::Windows::Forms::Label^  label4;
    private: System::Windows::Forms::Label^  label5;
 
    private:
        /// <summary>
        /// Обязательная переменная конструктора.
        /// </summary>
        System::ComponentModel::Container ^components;
 
#pragma region Windows Form Designer generated code
        /// <summary>
        /// Требуемый метод для поддержки конструктора — не изменяйте 
        /// содержимое этого метода с помощью редактора кода.
        /// </summary>
        void InitializeComponent(void)
        {
            System::Windows::Forms::DataVisualization::Charting::ChartArea^  chartArea1 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
            System::Windows::Forms::DataVisualization::Charting::Legend^  legend1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
            System::Windows::Forms::DataVisualization::Charting::Series^  series1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series2 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series3 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series4 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            System::Windows::Forms::DataVisualization::Charting::Series^  series5 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
            this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
            this->textBox1 = (gcnew System::Windows::Forms::TextBox());
            this->textBox2 = (gcnew System::Windows::Forms::TextBox());
            this->textBox3 = (gcnew System::Windows::Forms::TextBox());
            this->textBox4 = (gcnew System::Windows::Forms::TextBox());
            this->textBox5 = (gcnew System::Windows::Forms::TextBox());
            this->label1 = (gcnew System::Windows::Forms::Label());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->button2 = (gcnew System::Windows::Forms::Button());
            this->button3 = (gcnew System::Windows::Forms::Button());
            this->label2 = (gcnew System::Windows::Forms::Label());
            this->label3 = (gcnew System::Windows::Forms::Label());
            this->label4 = (gcnew System::Windows::Forms::Label());
            this->label5 = (gcnew System::Windows::Forms::Label());
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->BeginInit();
            this->SuspendLayout();
            // 
            // chart1
            // 
            chartArea1->Name = L"ChartArea1";
            this->chart1->ChartAreas->Add(chartArea1);
            legend1->Name = L"Legend1";
            this->chart1->Legends->Add(legend1);
            this->chart1->Location = System::Drawing::Point(0, -1);
            this->chart1->Name = L"chart1";
            series1->ChartArea = L"ChartArea1";
            series1->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
            series1->Color = System::Drawing::Color::Black;
            series1->Legend = L"Legend1";
            series1->Name = L"Series1";
            series2->ChartArea = L"ChartArea1";
            series2->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
            series2->Color = System::Drawing::Color::Black;
            series2->Legend = L"Legend1";
            series2->Name = L"Series2";
            series3->ChartArea = L"ChartArea1";
            series3->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
            series3->Color = System::Drawing::Color::Black;
            series3->Legend = L"Legend1";
            series3->Name = L"Series3";
            series4->ChartArea = L"ChartArea1";
            series4->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Point;
            series4->Color = System::Drawing::Color::Blue;
            series4->Legend = L"Legend1";
            series4->Name = L"Series4";
            series5->ChartArea = L"ChartArea1";
            series5->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Point;
            series5->Color = System::Drawing::Color::Blue;
            series5->Legend = L"Legend1";
            series5->Name = L"Series5";
            this->chart1->Series->Add(series1);
            this->chart1->Series->Add(series2);
            this->chart1->Series->Add(series3);
            this->chart1->Series->Add(series4);
            this->chart1->Series->Add(series5);
            this->chart1->Size = System::Drawing::Size(460, 214);
            this->chart1->TabIndex = 0;
            this->chart1->Text = L"chart1";
            // 
            // textBox1
            // 
            this->textBox1->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox1->Location = System::Drawing::Point(200, 226);
            this->textBox1->Name = L"textBox1";
            this->textBox1->Size = System::Drawing::Size(45, 20);
            this->textBox1->TabIndex = 1;
            this->textBox1->Text = L"10000";
            // 
            // textBox2
            // 
            this->textBox2->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox2->Location = System::Drawing::Point(92, 287);
            this->textBox2->Name = L"textBox2";
            this->textBox2->ReadOnly = true;
            this->textBox2->Size = System::Drawing::Size(85, 20);
            this->textBox2->TabIndex = 2;
            // 
            // textBox3
            // 
            this->textBox3->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox3->Location = System::Drawing::Point(92, 319);
            this->textBox3->Name = L"textBox3";
            this->textBox3->ReadOnly = true;
            this->textBox3->Size = System::Drawing::Size(85, 20);
            this->textBox3->TabIndex = 3;
            // 
            // textBox4
            // 
            this->textBox4->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox4->Location = System::Drawing::Point(336, 282);
            this->textBox4->Name = L"textBox4";
            this->textBox4->ReadOnly = true;
            this->textBox4->Size = System::Drawing::Size(97, 20);
            this->textBox4->TabIndex = 4;
            // 
            // textBox5
            // 
            this->textBox5->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle;
            this->textBox5->Location = System::Drawing::Point(336, 320);
            this->textBox5->Name = L"textBox5";
            this->textBox5->ReadOnly = true;
            this->textBox5->Size = System::Drawing::Size(97, 20);
            this->textBox5->TabIndex = 5;
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(90, 226);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(87, 13);
            this->label1->TabIndex = 6;
            this->label1->Text = L"Сколько точек\?";
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(24, 363);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(101, 37);
            this->button1->TabIndex = 11;
            this->button1->Text = L"Фигура";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(180, 363);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(97, 37);
            this->button2->TabIndex = 12;
            this->button2->Text = L"Расчет";
            this->button2->UseVisualStyleBackColor = true;
            this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(336, 363);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(88, 37);
            this->button3->TabIndex = 13;
            this->button3->Text = L"Выход";
            this->button3->UseVisualStyleBackColor = true;
            // 
            // label2
            // 
            this->label2->AutoSize = true;
            this->label2->Location = System::Drawing::Point(3, 289);
            this->label2->Name = L"label2";
            this->label2->Size = System::Drawing::Size(74, 13);
            this->label2->TabIndex = 14;
            this->label2->Text = L"Точек внутри";
            // 
            // label3
            // 
            this->label3->AutoSize = true;
            this->label3->Location = System::Drawing::Point(3, 319);
            this->label3->Name = L"label3";
            this->label3->Size = System::Drawing::Size(83, 13);
            this->label3->TabIndex = 15;
            this->label3->Text = L"Точек снаружи";
            // 
            // label4
            // 
            this->label4->AutoSize = true;
            this->label4->Location = System::Drawing::Point(225, 282);
            this->label4->Name = L"label4";
            this->label4->Size = System::Drawing::Size(95, 13);
            this->label4->TabIndex = 16;
            this->label4->Text = L"Площадь фигуры";
            // 
            // label5
            // 
            this->label5->AutoSize = true;
            this->label5->Location = System::Drawing::Point(234, 319);
            this->label5->Name = L"label5";
            this->label5->Size = System::Drawing::Size(86, 13);
            this->label5->TabIndex = 17;
            this->label5->Text = L"Погрешность %";
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(462, 406);
            this->Controls->Add(this->label5);
            this->Controls->Add(this->label4);
            this->Controls->Add(this->label3);
            this->Controls->Add(this->label2);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->textBox5);
            this->Controls->Add(this->textBox4);
            this->Controls->Add(this->textBox3);
            this->Controls->Add(this->textBox2);
            this->Controls->Add(this->textBox1);
            this->Controls->Add(this->chart1);
            this->Name = L"MyForm";
            this->Text = L"MyForm";
            this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
            (cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->EndInit();
            this->ResumeLayout(false);
            this->PerformLayout();
 
        }
 
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    Series^plot1 = chart1->Series[0];
    Series^plot2 = chart1->Series[1];
    Series^plot3 = chart1->Series[2];
    double y, x;
    for (int i = -100; i <= 100; i++)
    {
        x = i;
        y = sqrt(10000 - x*x);
        plot1->Points->AddXY(x, y);
    }
    for (int i = -100; i <= 100; i++)
    {
        x = i;
        y = -0.5*(x + 100);
        plot2->Points->AddXY(x, y);
    }
    for (int i = -100; i <= 0; i++)
    {
        x = 100;
        y = i;
        plot3->Points->AddXY(x, y);
    }
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
    Series^plot4 = chart1->Series[3];
    Series^plot5 = chart1->Series[4];
    int T_vn, T_za, n;
    float x, y, S_fig, S_r, er, M_PI = 0;
    plot4->Points->Clear();
    plot5->Points->Clear();
    if (textBox1->Text != "")
    {
        n = Convert::ToInt32(textBox1->Text);
        T_vn = 0; T_za = 0;
        for (int i = 1; 1 <= n; i++)
        {
            x = rand() % 201 - 100;
            y = rand() % 201 - 100;
        }
        if (((x*x + y*y <= 10000) && (y >= 0)) || ((y<0) && (x <= 100) && (y >= -0.5*(x + 100))))
        {
            plot4->Points->AddXY(x, y); T_vn++;
        }
        else
        {
            plot5->Points->AddXY(x, y); T_za++;
        }
        textBox2->Text = Convert::ToString(T_vn);
        textBox3->Text = Convert::ToString(T_za);
        S_fig = 40000 * T_vn / n;
        S_r = 10000 + M_PI * 10000 / 2;
        er = fabs(S_r - S_fig) / S_r * 100;
        textBox4->Text = Convert::ToString(S_fig);
        textBox5->Text = Convert::ToString(er);
    }
}
private: System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
}
};
}
0
Модератор
Эксперт С++
13507 / 10757 / 6412
Регистрация: 18.12.2011
Сообщений: 28,712
18.11.2017, 11:35 8
В 318 строке уберите
Цитата Сообщение от Renounced Посмотреть сообщение
M_PI = 0
А
Цитата Сообщение от Renounced Посмотреть сообщение
C++
1
2
x = rand() % 201 - 100; 
y = rand() % 201 - 100;
Можете записать как
C++
1
2
x = float(rand() % 201 - 100); 
y = float(rand() % 201 - 100);
или
C++
1
2
x = rand() % 201 - 100.f; 
y = rand() % 201 - 100.f;
Но это не ошибка, а просто предупреждение.
Еще настоятельно советую везде float Заменить на double
0
18.11.2017, 11:35
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
18.11.2017, 11:35
Помогаю со студенческими работами здесь

Warning C4700: использована неинициализированная локальная переменная "matrix"
тогда еще 1 вопрос: при попытке реализовать чтение из файла в виде функции: #include &lt;fstream&gt;...

Warning C4700: использована неинициализированная локальная переменная "d"
#include &lt;iostream&gt; #include &lt;conio.h&gt; #include &lt;cmath&gt; using namespace std; int main() {...

Исправить ошибку: error C4700: использована неинициализированная локальная переменная "n"
перевожу с С++ на Си такой код: Код С++: #include &quot;stdafx.h&quot; #include &lt;iostream&gt; ...

Error C4700: использована неинициализированная локальная переменная
Строка 52 #include &quot;stdafx.h&quot; #include &quot;stdio.h&quot; #include &quot;iostream&quot; #include &quot;math.h&quot;...

Error C4700: использована неинициализированная локальная переменная
int nrhero; string K; for (i = 0; i != 1000000000000; i++) { nrhero = nrhero + 1; if...

Error C4700: использована неинициализированная локальная переменная
Сформировать вектор из произведений элементов столбцов и найти их среднее арифметическое Вот мой...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
8
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru