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
| #pragma once
namespace task5 {
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>
/// Сводка для 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::ErrorProvider^ errorProvider1;
protected:
private: System::Windows::Forms::DataGridView^ grdMasOutput;
private: System::Windows::Forms::DataGridView^ grdMasInput;
private: System::Windows::Forms::Button^ Calc;
private: System::Windows::Forms::Button^ btnAddLine;
private: System::Windows::Forms::Button^ btnAddColum;
private: System::Windows::Forms::Button^ btnDelColum;
private: System::Windows::Forms::Button^ btnDelLine;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ cl1;
private: System::Windows::Forms::DataGridViewTextBoxColumn^ cl;
private: System::ComponentModel::IContainer^ components;
private:
/// <summary>
/// Обязательная переменная конструктора.
/// </summary>
#pragma region Windows Form Designer generated code
/// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте
/// содержимое этого метода с помощью редактора кода.
/// </summary>
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->errorProvider1 = (gcnew System::Windows::Forms::ErrorProvider(this->components));
this->btnDelLine = (gcnew System::Windows::Forms::Button());
this->btnDelColum = (gcnew System::Windows::Forms::Button());
this->btnAddColum = (gcnew System::Windows::Forms::Button());
this->btnAddLine = (gcnew System::Windows::Forms::Button());
this->Calc = (gcnew System::Windows::Forms::Button());
this->grdMasInput = (gcnew System::Windows::Forms::DataGridView());
this->cl = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
this->grdMasOutput = (gcnew System::Windows::Forms::DataGridView());
this->cl1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->errorProvider1))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->grdMasInput))->BeginInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->grdMasOutput))->BeginInit();
this->SuspendLayout();
//
// errorProvider1
//
this->errorProvider1->ContainerControl = this;
//
// btnDelLine
//
this->btnDelLine->Location = System::Drawing::Point(12, 356);
this->btnDelLine->Name = L"btnDelLine";
this->btnDelLine->Size = System::Drawing::Size(107, 23);
this->btnDelLine->TabIndex = 0;
this->btnDelLine->Text = L"Удалить строку";
this->btnDelLine->UseVisualStyleBackColor = true;
this->btnDelLine->Click += gcnew System::EventHandler(this, &MyForm::btnDelLine_Click);
//
// btnDelColum
//
this->btnDelColum->Location = System::Drawing::Point(150, 356);
this->btnDelColum->Name = L"btnDelColum";
this->btnDelColum->Size = System::Drawing::Size(110, 23);
this->btnDelColum->TabIndex = 1;
this->btnDelColum->Text = L"Удалить столбец";
this->btnDelColum->UseVisualStyleBackColor = true;
this->btnDelColum->Click += gcnew System::EventHandler(this, &MyForm::btnDelColum_Click);
//
// btnAddColum
//
this->btnAddColum->Location = System::Drawing::Point(150, 327);
this->btnAddColum->Name = L"btnAddColum";
this->btnAddColum->Size = System::Drawing::Size(110, 23);
this->btnAddColum->TabIndex = 2;
this->btnAddColum->Text = L"Добавить столбец";
this->btnAddColum->UseVisualStyleBackColor = true;
this->btnAddColum->Click += gcnew System::EventHandler(this, &MyForm::btnAddColum_Click);
//
// btnAddLine
//
this->btnAddLine->Location = System::Drawing::Point(12, 327);
this->btnAddLine->Name = L"btnAddLine";
this->btnAddLine->Size = System::Drawing::Size(107, 23);
this->btnAddLine->TabIndex = 3;
this->btnAddLine->Text = L"Добавить строку";
this->btnAddLine->UseVisualStyleBackColor = true;
this->btnAddLine->Click += gcnew System::EventHandler(this, &MyForm::btnAddLine_Click);
//
// Calc
//
this->Calc->Location = System::Drawing::Point(606, 327);
this->Calc->Name = L"Calc";
this->Calc->Size = System::Drawing::Size(75, 23);
this->Calc->TabIndex = 4;
this->Calc->Text = L"Решить";
this->Calc->UseVisualStyleBackColor = true;
this->Calc->Click += gcnew System::EventHandler(this, &MyForm::Calc_Click);
//
// grdMasInput
//
this->grdMasInput->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->grdMasInput->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(1) { this->cl });
this->grdMasInput->Location = System::Drawing::Point(12, 12);
this->grdMasInput->Name = L"grdMasInput";
this->grdMasInput->Size = System::Drawing::Size(266, 309);
this->grdMasInput->TabIndex = 5;
//
// cl
//
this->cl->HeaderText = L"";
this->cl->Name = L"cl";
//
// grdMasOutput
//
this->grdMasOutput->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->grdMasOutput->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^ >(1) { this->cl1 });
this->grdMasOutput->Location = System::Drawing::Point(482, 12);
this->grdMasOutput->Name = L"grdMasOutput";
this->grdMasOutput->Size = System::Drawing::Size(273, 309);
this->grdMasOutput->TabIndex = 6;
//
// cl1
//
this->cl1->HeaderText = L"";
this->cl1->Name = L"cl1";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(767, 384);
this->Controls->Add(this->grdMasOutput);
this->Controls->Add(this->grdMasInput);
this->Controls->Add(this->Calc);
this->Controls->Add(this->btnAddLine);
this->Controls->Add(this->btnAddColum);
this->Controls->Add(this->btnDelColum);
this->Controls->Add(this->btnDelLine);
this->MinimizeBox = false;
this->Name = L"MyForm";
this->Text = L"Обработка табличных данных 2";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->errorProvider1))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->grdMasInput))->EndInit();
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->grdMasOutput))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void btnAddLine_Click(System::Object^ sender, System::EventArgs^ e)//Добавление строки
{
this->grdMasInput->Rows->Add(1);
}
private: System::Void btnDelLine_Click(System::Object^ sender, System::EventArgs^ e) {//Удаление строки
if (!this->grdMasInput->CurrentRow->IsNewRow)
{
int i = this->grdMasInput->CurrentRow->Index;
this->grdMasInput->Rows->Remove(this->grdMasInput->Rows[i]);
}
}
private: System::Void btnAddColum_Click(System::Object^ sender, System::EventArgs^ e) //Добавление столбца
{
DataGridViewTextBoxColumn^newc = gcnew DataGridViewTextBoxColumn();
this->grdMasInput->Columns->Add(newc);
}
private: System::Void btnDelColum_Click(System::Object^ sender, System::EventArgs^ e) //Удаление столбца
{
this->grdMasInput->Columns->Remove(this->grdMasInput->Columns[this->grdMasInput->ColumnCount-1]);
}
private: System::Void Calc_Click(System::Object^ sender, System::EventArgs^ e) //Кнопка решения
{
int x;
int max = 0;
int min = System::Convert::ToInt32(this->grdMasInput->Rows[0]->Cells[0]->Value);//объявляем переменные
int maxJ = 0;
int minJ = 0;
for (int i = 0; i < this->grdMasInput->RowCount - 1; i++)
{
for (int j = 0; j < this->grdMasInput->ColumnCount - 1; i++)
{
min = System::Convert::ToInt32(this->grdMasInput->Rows[0]->Cells[0]->Value);
x = System::Convert::ToInt32(this->grdMasInput->Rows[i]->Cells[j]->Value);
if (x > max)
{
max = x;
maxJ = j;
}
if (x < min)
{
min = x;
minJ = j;
}
}
}
}
};
} |