Лабораторная работа по предмету: Программирование Работа с компонентами. Понятие и свойства компонентов



Download 0,99 Mb.
Sana17.07.2022
Hajmi0,99 Mb.
#810731
TuriЛабораторная работа
Bog'liq
lab 8


ТАШКЕНТСКИЙ УНИВЕРСИТЕТ
ИНФОРМАЦИОННЫХ ТЕХНОЛОГИЙ ИМЕНИ
МУХАММАДА АЛ-ХОРАЗМИЙ

Группа ДИФ 320-21


Лабораторная работа
по предмету: Программирование
Работа с компонентами. Понятие и свойства компонентов.
Вариант №4

Выполнил: Арутюнян Д.
Принял: профессор Абдуллаева З.


Цель работы: Изучить все компоненты среды Visual C++ и разработка алгоритмов выполнения задач с ними.
Поставленная задача: Создание элементов основных компонентов среды Visual C++, разработка программы выполнения различных действий на нем.
Работа в режиме Windows Application в программе Visual C++: Образец выполнения данной программы задается учебно-методическим пособием (25-31 стр.)

Скриншоты:




Код:
#pragma once

#include

namespace Project2 {

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 for MyForm
///

public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}

protected:


///
/// Clean up any resources being used.
///

~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::PictureBox^ pictureBox1;
private: System::Windows::Forms::DataGridView^ dataGridView1;
private: System::Windows::Forms::Label^ label1;
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: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
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::TextBox^ textBox6;

protected:

private:
///


/// Required designer variable.
///

System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code


///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(MyForm::typeid));
this->button1 = (gcnew System::Windows::Forms::Button());
this->button2 = (gcnew System::Windows::Forms::Button());
this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
this->label1 = (gcnew System::Windows::Forms::Label());
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());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
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->textBox6 = (gcnew System::Windows::Forms::TextBox());
(cli::safe_cast(this->pictureBox1))->BeginInit();
(cli::safe_cast(this->dataGridView1))->BeginInit();
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(494, 555);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(270, 69);
this->button1->TabIndex = 0;
this->button1->Text = L"Show table and function extremes";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click_1);
//
// button2
//
this->button2->Location = System::Drawing::Point(779, 555);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(160, 69);
this->button2->TabIndex = 1;
this->button2->Text = L"Exit";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
//
// pictureBox1
//
this->pictureBox1->Image = (cli::safe_cast(resources->GetObject(L"pictureBox1.Image")));
this->pictureBox1->Location = System::Drawing::Point(0, 2);
this->pictureBox1->Name = L"pictureBox1";
this->pictureBox1->Size = System::Drawing::Size(419, 353);
this->pictureBox1->TabIndex = 2;
this->pictureBox1->TabStop = false;
//
// dataGridView1
//
this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
this->dataGridView1->Location = System::Drawing::Point(472, 32);
this->dataGridView1->Name = L"dataGridView1";
this->dataGridView1->RowHeadersWidth = 62;
this->dataGridView1->RowTemplate->Height = 28;
this->dataGridView1->Size = System::Drawing::Size(411, 323);
this->dataGridView1->TabIndex = 3;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(8, 419);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(122, 20);
this->label1->TabIndex = 4;
this->label1->Text = L"Write value XN=";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(14, 490);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(121, 20);
this->label2->TabIndex = 5;
this->label2->Text = L"Write value XK=";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(14, 558);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(123, 20);
this->label3->TabIndex = 6;
this->label3->Text = L"Write value XH=";
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(21, 619);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(109, 20);
this->label4->TabIndex = 7;
this->label4->Text = L"Write value a=";
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(638, 9);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(115, 20);
this->label5->TabIndex = 8;
this->label5->Text = L"Table of values";
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(544, 425);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(79, 20);
this->label6->TabIndex = 9;
this->label6->Text = L"Max value";
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(787, 425);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(75, 20);
this->label7->TabIndex = 10;
this->label7->Text = L"Min value";
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(147, 419);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(341, 26);
this->textBox1->TabIndex = 11;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(147, 487);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(341, 26);
this->textBox2->TabIndex = 12;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(147, 555);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(341, 26);
this->textBox3->TabIndex = 13;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(147, 619);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(341, 26);
this->textBox4->TabIndex = 14;
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(505, 484);
this->textBox5->Name = L"textBox5";
this->textBox5->ReadOnly = true;
this->textBox5->Size = System::Drawing::Size(183, 26);
this->textBox5->TabIndex = 15;
//
// textBox6
//
this->textBox6->Location = System::Drawing::Point(745, 484);
this->textBox6->Name = L"textBox6";
this->textBox6->ReadOnly = true;
this->textBox6->Size = System::Drawing::Size(194, 26);
this->textBox6->TabIndex = 16;
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(9, 20);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(978, 664);
this->Controls->Add(this->textBox6);
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->label7);
this->Controls->Add(this->label6);
this->Controls->Add(this->label5);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->dataGridView1);
this->Controls->Add(this->pictureBox1);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
this->Name = L"MyForm";
this->Text = L"Prepared by Arutyunyan D.";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
(cli::safe_cast(this->pictureBox1))->EndInit();
(cli::safe_cast(this->dataGridView1))->EndInit();
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) {

double xn, xk, xh, x, y, a, ymax, ymin, yt;


int n, i;

if ((textBox1->Text != "") && (textBox2->Text != "") &&
(textBox3->Text != "") && (textBox4->Text != ""))
{

xn = Convert::ToDouble(textBox1->Text);
xk = Convert::ToDouble(textBox2->Text);
xh = Convert::ToDouble(textBox3->Text);
a= Convert::ToDouble(textBox4->Text);

dataGridView1->Columns->Clear();

dataGridView1->ColumnCount = 2;

dataGridView1->Rows->Add(ceil((xk - n) / xh) + 1);

dataGridView1->Columns[0]->Name = " X";
dataGridView1->Columns[1]->Name = " Y";
i = 0;
x = xn;
ymax = -1.8e307; ymin = 1.8e307;
while (x <= xk)
{
if (x <= 0&&x>=-3.7) { y = pow(abs(x),x+2)+sin(x); }
else {
if (a <= 8.5) {
if (x < a) {
y = pow(3, x + 2) + 2 * x;
}
else {
y = pow(x*x+x+1,0.2);
}
}
else {
a = 1;
}

}


dataGridView1->Rows[i]->Cells[0]->Value = Convert::ToString(x);

yt = ceil(y * 100) / 100;

dataGridView1->Rows[i]->Cells[1]->Value
= Convert::ToString(yt);

if (y > ymax) ymax = ceil(y * 100) / 100; if
(y < ymin) ymin = ceil(y * 100) / 100;
x = x + xh;
i++;
}

textBox5->Text = Convert::ToString(ymax);
textBox6->Text = Convert::ToString(ymin);
}
else {
MessageBox::Show("Заполните, пожалуйста, данные",
"Ошибка ввода данных",
MessageBoxButtons::OK, MessageBoxIcon::Exclamation);
}

}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {


Application::Exit();
}
};

};
Download 0,99 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish