0% found this document useful (0 votes)
1 views4 pages

Abdijabborov Dovurbek PRG001-1-Tekshirdi - Shokirov Shodmon Shoyimovich

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views4 pages

Abdijabborov Dovurbek PRG001-1-Tekshirdi - Shokirov Shodmon Shoyimovich

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Abdijabborov Dovurbek PRG001-1-Tekshirdi -

Shokirov Shodmon Shoyimovich

Dastur kodi
#pragma once
#include <algorithm>

namespace WindowsFormsApplication11 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

public ref class Form1 : public System::Windows::Forms::Form {


public:
Form1(void) {
InitializeComponent();
}

protected:
~Form1() {
if (components) {
delete components;
}
}
private: System::Windows::Forms::Label^ label1;
protected:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::DataGridView^ dataGridView1;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Label^ label3;

private:

System::ComponentModel::Container ^components;

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->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->dataGridView1 = (gcnew
System::Windows::Forms::DataGridView());
this->label4 = (gcnew System::Windows::Forms::Label());
this->button1 = (gcnew System::Windows::Forms::Button());
this->label3 = (gcnew System::Windows::Forms::Label());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
>(this->dataGridView1))->BeginInit();
this->SuspendLayout();
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(45, 124);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(27, 13);
this->label1->TabIndex = 7;
this->label1->Text = L"N = ";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(45, 154);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(28, 13);
this->label2->TabIndex = 6;
this->label2->Text = L"M = ";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(81, 121);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(100, 20);
this->textBox1->TabIndex = 5;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(81, 151);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(100, 20);
this->textBox2->TabIndex = 4;
//
// dataGridView1
//
this->dataGridView1->ColumnHeadersHeightSizeMode =
System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView1->Location = System::Drawing::Point(247,
121);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->Size = System::Drawing::Size(400, 300);
this->dataGridView1->TabIndex = 2;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(45, 284);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(0, 13);
this->label4->TabIndex = 0;
//
// button1
//
this->button1->Location = System::Drawing::Point(81, 234);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(100, 23);
this->button1->TabIndex = 1;
this->button1->Text = L"Hisobla";
this->button1->Click += gcnew System::EventHandler(this,
&Form1::button1_Click);
//
// label3
//
this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft
Sans Serif", 9.75F, System::Drawing::FontStyle::Bold,
System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(204)));
this->label3->Location = System::Drawing::Point(81, 9);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(566, 83);
this->label3->TabIndex = 8;
this->label3->Text = resources->GetString(L"label3.Text");
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode =
System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(684, 433);
this->Controls->Add(this->label3);
this->Controls->Add(this->label4);
this->Controls->Add(this->button1);
this->Controls->Add(this->dataGridView1);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Name = L"Form1";
this->Text = L"Form1";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^
>(this->dataGridView1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();

void button1_Click(System::Object^ sender, System::EventArgs^ e) {


int N = System::Convert::ToInt32(textBox1->Text);
int M = System::Convert::ToInt32(textBox2->Text);
array<int, 2>^ a = gcnew array<int, 2>(N, M);
Random^ rnd = gcnew Random();

for (int i = 0; i < N; i++) {


for (int j = 0; j < M; j++) {
a[i, j] = rnd->Next(-1000, 1001);
}
}

dataGridView1->RowCount = N;
dataGridView1->ColumnCount = M;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
dataGridView1->Rows[i]->Cells[j]->Value = a[i, j];
}
}

label4->Text = "Natija:" + Environment::NewLine;


for (int i = 0; i < N; i++) {
array<int>^ row = gcnew array<int>(M);
for (int j = 0; j < M; j++) {
row[j] = a[i, j];
}
Array::Sort(row);
for (int j = 0; j < M; j++) {
label4->Text += row[j].ToString() + " |";
}
label4->Text += Environment::NewLine;
}
}

};
}

Natija

You might also like