Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include<math.h>
- #include <cmath>
- #include <stdlib.h>
- int m, n,kol,p;
- int A[50][50];
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- if ((textBox1->Text!="")&&(textBox2->Text!=""))
- {
- int stb; int str; int i;
- m = Convert::ToInt32(textBox1->Text);
- n = Convert::ToInt32(textBox2->Text);
- int k =0;
- k = dataGridView1->ColumnCount;
- if (k != 0)
- for (int i = 0; i < k; i++)
- dataGridView1->Columns->Clear();
- dataGridView1->ColumnCount = n;
- dataGridView1->Rows->Add(m);
- for (stb=0; stb<m; stb++)
- {
- for (str=0; str<n; str++)
- {
- i = rand ( ) % 121-50;
- dataGridView1->Rows[str]->Cells[stb]->Value = i;
- }
- }
- }
- else {MessageBox::Show( "Заполните пожалуйста данные", "Ошибка ввода данных", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );}
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- kol=0;p=0;
- int chet=0; int sum1=0; int sum2=0; int i; int j;
- for (int i = 0; i < m; i++)
- for (int j = 0; j < n; j++)
- {
- A[i][j] = Convert::ToSingle(this->dataGridView1->Rows[i]->Cells[j]->Value);
- if (A[i][j]>0) {kol++;}
- }
- j=1;
- for (int i = 0; i < m; i++)
- {
- if (A[i][j]<0) {sum2=sum2+A[i][j];}
- }
- i=1;
- for (int j = 0; j < n; j++)
- {
- if (A[i][j]%3==true) {sum1=sum1+A[i][j];}
- }
- if (checkBox3->Checked==true) {this->textBox5->Text=Convert::ToString (sum1*sum2);}
- if ((checkBox1->Checked==true)&&(kol!=0)) {this->textBox3->Text=Convert::ToString (kol);}
- else
- if (checkBox1->Checked==true) {this->textBox3->Text=Convert::ToString ("Нет элементов");}
- for (int j = n-1; j >= 0; j--)
- {
- if (A[p][j]%2==0) {chet=chet+1;}
- p++;
- }
- if ((checkBox2->Checked==true)&&(chet!=0)) {this->textBox4->Text=Convert::ToString (chet);}
- else
- if (checkBox2->Checked==true) {this->textBox4->Text=Convert::ToString ("Нет элементов");}
- return;
- }
- private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { Application::Exit();
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment