Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //завдання 1
- #pragma once
- #include <math.h>
- namespace rozr2n {
- 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 main : public System::Windows::Forms::Form
- {
- public:
- main(void)
- {
- InitializeComponent();
- }
- protected:
- ~main()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label4;
- protected:
- private:
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- void InitializeComponent(void)
- {
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label3 = (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->button1 = (gcnew System::Windows::Forms::Button());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->SuspendLayout();
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(12, 12);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(32, 13);
- this->label1->TabIndex = 0;
- this->label1->Text = L"Сила";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(12, 36);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(66, 13);
- this->label2->TabIndex = 1;
- this->label2->Text = L"Жорсткість";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(12, 60);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(54, 13);
- this->label3->TabIndex = 2;
- this->label3->Text = L"Довжина";
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(100, 9);
- this->textBox1->Name = L"textBox1";
- this->textBox1->ReadOnly = true;
- this->textBox1->Size = System::Drawing::Size(159, 20);
- this->textBox1->TabIndex = 3;
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(100, 33);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(159, 20);
- this->textBox2->TabIndex = 4;
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(100, 57);
- this->textBox3->Name = L"textBox3";
- this->textBox3->Size = System::Drawing::Size(159, 20);
- this->textBox3->TabIndex = 5;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(12, 85);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(76, 23);
- this->button1->TabIndex = 6;
- this->button1->Text = L"Обчислити";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &main::button1_Click);
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(97, 90);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(0, 13);
- this->label4->TabIndex = 7;
- //
- // main
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(287, 117);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox3);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Name = L"main";
- this->Text = L"Обчислення сили пружності";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- label4->Text = "";
- if (textBox2->Text != "" && textBox3->Text != "") {
- double k = Convert::ToDouble(textBox2->Text);
- double x = Convert::ToDouble(textBox3->Text);
- textBox1->Text = double(k * x * x) + "";
- } else {
- label4->Text = "Введених даних недостатньо";
- return;
- }
- }
- };
- }
- //завдання 2
- #pragma once
- #include <math.h>
- namespace rozr2n {
- 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 main : public System::Windows::Forms::Form
- {
- public:
- main(void)
- {
- InitializeComponent();
- }
- protected:
- ~main()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::Label^ label1;
- private: System::Windows::Forms::Label^ label2;
- private: System::Windows::Forms::Label^ label3;
- private: System::Windows::Forms::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Label^ label4;
- private: System::Windows::Forms::Button^ button2;
- protected:
- private:
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- void InitializeComponent(void)
- {
- this->label1 = (gcnew System::Windows::Forms::Label());
- this->label2 = (gcnew System::Windows::Forms::Label());
- this->label3 = (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->button1 = (gcnew System::Windows::Forms::Button());
- this->label4 = (gcnew System::Windows::Forms::Label());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->SuspendLayout();
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(12, 12);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(32, 13);
- this->label1->TabIndex = 0;
- this->label1->Text = L"Сила";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(12, 36);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(66, 13);
- this->label2->TabIndex = 1;
- this->label2->Text = L"Жорсткість";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(12, 60);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(54, 13);
- this->label3->TabIndex = 2;
- this->label3->Text = L"Довжина";
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(100, 9);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(159, 20);
- this->textBox1->TabIndex = 3;
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(100, 33);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(159, 20);
- this->textBox2->TabIndex = 4;
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(100, 57);
- this->textBox3->Name = L"textBox3";
- this->textBox3->Size = System::Drawing::Size(159, 20);
- this->textBox3->TabIndex = 5;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(12, 85);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(76, 23);
- this->button1->TabIndex = 6;
- this->button1->Text = L"Обчислити";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &main::button1_Click);
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(97, 90);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(0, 13);
- this->label4->TabIndex = 7;
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(12, 114);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(247, 23);
- this->button2->TabIndex = 8;
- this->button2->Text = L"Очистити";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &main::button2_Click);
- //
- // main
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(287, 144);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox3);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Name = L"main";
- this->Text = L"Обчислення сили пружності";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- label4->Text = "";
- if (textBox1->Text != "" && textBox2->Text != "") {
- double F = Convert::ToDouble(textBox1->Text);
- double k = Convert::ToDouble(textBox2->Text);
- textBox3->ReadOnly = true;
- textBox3->Text = sqrt(F / k) + "";
- }
- else if (textBox2->Text != "" && textBox3->Text != "") {
- double k = Convert::ToDouble(textBox2->Text);
- double x = Convert::ToDouble(textBox3->Text);
- textBox1->ReadOnly = true;
- textBox1->Text = double(k * x * x) + "";
- }
- else if (textBox3->Text != "" && textBox1->Text != "") {
- double F = Convert::ToDouble(textBox1->Text);
- double x = Convert::ToDouble(textBox3->Text);
- textBox2->ReadOnly = true;
- textBox2->Text = double(F / (x*x)) + "";
- }
- else {
- label4->Text = "Введених даних недостатньо";
- return;
- }
- }
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- label4->Text = "";
- textBox1->Text = "";
- textBox1->ReadOnly = false;
- textBox2->Text = "";
- textBox2->ReadOnly = false;
- textBox3->Text = "";
- textBox3->ReadOnly = false;
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement