Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- namespace Project9 {
- 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::Label^ L_a;
- protected:
- private: System::Windows::Forms::Label^ L_b;
- private: System::Windows::Forms::Label^ L_c;
- private: System::Windows::Forms::Label^ L_x2;
- private: System::Windows::Forms::Label^ L_x1;
- private: System::Windows::Forms::TextBox^ In_a;
- private: System::Windows::Forms::TextBox^ In_b;
- private: System::Windows::Forms::TextBox^ In_c;
- private: System::Windows::Forms::Button^ button1;
- private: System::Windows::Forms::Button^ button2;
- private: System::Windows::Forms::Label^ L_per1;
- private: System::Windows::Forms::Label^ L_per2;
- private: System::Windows::Forms::Label^ L_D;
- private:
- /// <summary>
- /// Обязательная переменная конструктора.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Требуемый метод для поддержки конструктора — не изменяйте
- /// содержимое этого метода с помощью редактора кода.
- /// </summary>
- void InitializeComponent(void)
- {
- this->L_a = (gcnew System::Windows::Forms::Label());
- this->L_b = (gcnew System::Windows::Forms::Label());
- this->L_c = (gcnew System::Windows::Forms::Label());
- this->L_x2 = (gcnew System::Windows::Forms::Label());
- this->L_x1 = (gcnew System::Windows::Forms::Label());
- this->In_a = (gcnew System::Windows::Forms::TextBox());
- this->In_b = (gcnew System::Windows::Forms::TextBox());
- this->In_c = (gcnew System::Windows::Forms::TextBox());
- this->button1 = (gcnew System::Windows::Forms::Button());
- this->button2 = (gcnew System::Windows::Forms::Button());
- this->L_per1 = (gcnew System::Windows::Forms::Label());
- this->L_per2 = (gcnew System::Windows::Forms::Label());
- this->L_D = (gcnew System::Windows::Forms::Label());
- this->SuspendLayout();
- //
- // L_a
- //
- this->L_a->AutoSize = true;
- this->L_a->Location = System::Drawing::Point(68, 65);
- this->L_a->Name = L"L_a";
- this->L_a->Size = System::Drawing::Size(24, 17);
- this->L_a->TabIndex = 0;
- this->L_a->Text = L"a=";
- //
- // L_b
- //
- this->L_b->AutoSize = true;
- this->L_b->Location = System::Drawing::Point(68, 144);
- this->L_b->Name = L"L_b";
- this->L_b->Size = System::Drawing::Size(24, 17);
- this->L_b->TabIndex = 1;
- this->L_b->Text = L"b=";
- //
- // L_c
- //
- this->L_c->AutoSize = true;
- this->L_c->Location = System::Drawing::Point(68, 210);
- this->L_c->Name = L"L_c";
- this->L_c->Size = System::Drawing::Size(23, 17);
- this->L_c->TabIndex = 2;
- this->L_c->Text = L"c=";
- //
- // L_x2
- //
- this->L_x2->AutoSize = true;
- this->L_x2->Location = System::Drawing::Point(383, 112);
- this->L_x2->Name = L"L_x2";
- this->L_x2->Size = System::Drawing::Size(30, 17);
- this->L_x2->TabIndex = 3;
- this->L_x2->Text = L"x2=";
- this->L_x2->Visible = false;
- //
- // L_x1
- //
- this->L_x1->AutoSize = true;
- this->L_x1->Location = System::Drawing::Point(383, 68);
- this->L_x1->Name = L"L_x1";
- this->L_x1->Size = System::Drawing::Size(30, 17);
- this->L_x1->TabIndex = 4;
- this->L_x1->Text = L"x1=";
- this->L_x1->Visible = false;
- //
- // In_a
- //
- this->In_a->Location = System::Drawing::Point(158, 65);
- this->In_a->Name = L"In_a";
- this->In_a->Size = System::Drawing::Size(100, 22);
- this->In_a->TabIndex = 5;
- //
- // In_b
- //
- this->In_b->Location = System::Drawing::Point(158, 141);
- this->In_b->Name = L"In_b";
- this->In_b->Size = System::Drawing::Size(100, 22);
- this->In_b->TabIndex = 6;
- //
- // In_c
- //
- this->In_c->Location = System::Drawing::Point(158, 210);
- this->In_c->Name = L"In_c";
- this->In_c->Size = System::Drawing::Size(100, 22);
- this->In_c->TabIndex = 7;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(86, 331);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(170, 71);
- this->button1->TabIndex = 8;
- this->button1->Text = L"Розв\'язати";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
- //
- // button2
- //
- this->button2->Location = System::Drawing::Point(331, 331);
- this->button2->Name = L"button2";
- this->button2->Size = System::Drawing::Size(172, 71);
- this->button2->TabIndex = 9;
- this->button2->Text = L"Завершити";
- this->button2->UseVisualStyleBackColor = true;
- this->button2->Click += gcnew System::EventHandler(this, &MyForm::button2_Click);
- //
- // L_per1
- //
- this->L_per1->AutoSize = true;
- this->L_per1->Location = System::Drawing::Point(383, 144);
- this->L_per1->Name = L"L_per1";
- this->L_per1->Size = System::Drawing::Size(51, 17);
- this->L_per1->TabIndex = 10;
- this->L_per1->Text = L"В x1 = ";
- this->L_per1->Visible = false;
- //
- // L_per2
- //
- this->L_per2->AutoSize = true;
- this->L_per2->Location = System::Drawing::Point(383, 185);
- this->L_per2->Name = L"L_per2";
- this->L_per2->Size = System::Drawing::Size(47, 17);
- this->L_per2->TabIndex = 11;
- this->L_per2->Text = L"В x2 =";
- this->L_per2->Visible = false;
- //
- // L_D
- //
- this->L_D->AutoSize = true;
- this->L_D->Location = System::Drawing::Point(383, 234);
- this->L_D->Name = L"L_D";
- this->L_D->Size = System::Drawing::Size(26, 17);
- this->L_D->TabIndex = 12;
- this->L_D->Text = L"D=";
- this->L_D->Visible = false;
- //
- // MyForm
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->BackColor = System::Drawing::Color::Lime;
- this->ClientSize = System::Drawing::Size(850, 478);
- this->Controls->Add(this->L_D);
- this->Controls->Add(this->L_per2);
- this->Controls->Add(this->L_per1);
- this->Controls->Add(this->button2);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->In_c);
- this->Controls->Add(this->In_b);
- this->Controls->Add(this->In_a);
- this->Controls->Add(this->L_x1);
- this->Controls->Add(this->L_x2);
- this->Controls->Add(this->L_c);
- this->Controls->Add(this->L_b);
- this->Controls->Add(this->L_a);
- this->Name = L"MyForm";
- this->Text = L"MyForm";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
- Close();
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- double a, b, c, D, x1, x2, x,per,per1,per2;
- a = Convert::ToDouble(In_a->Text);
- b = Convert::ToDouble(In_b->Text);
- c = Convert::ToDouble(In_c->Text);
- D = Math::Pow(b, 2) - 4 * a*c;
- if (a == 0 && b == 0 && c == 0)
- {
- L_x2->Visible = false;
- L_per2->Visible = false;
- L_x1->Visible = false;
- L_per1->Visible = false;
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- L_x1->Visible = false;
- L_x2->Visible = false;
- MessageBox::Show("Rivnanja pogano obymovlene ");
- return;
- }
- else if (a == 0 && b != 0 && c == 0)
- {
- L_x2->Visible = false;
- L_per2->Visible = false;
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- x = 0;
- per = a*x*x + b*x + c;
- L_x1->Visible = true;
- L_per1->Visible = true;
- L_x1->Text = "x1 = x2 = " + Convert::ToString(x);
- L_per1->Text = "в x =" + Convert::ToString(per);
- return;
- }
- else if (a == 0 && b != 0 && c != 0)
- {
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- x = -c / b;
- per = a*x*x + b*x + c;
- L_x2->Visible = false;
- L_per2->Visible = false;
- L_x1->Visible = true;
- L_per1->Visible = true;
- L_x1->Text = "x1 = x2 = " + Convert::ToString(x);
- L_per1->Text = "в x = " + Convert::ToString(per);
- return;
- }
- else if (a == 0 && b == 0)
- {
- L_x2->Visible = false;
- L_per2->Visible = false;
- L_x1->Visible = false;
- L_per1->Visible = false;
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- MessageBox::Show("Rivnanja ne maje rozvjazkiv ");
- return;
- }
- else
- {
- D = b*b - 4 * a*c;
- if (D < 0)
- {
- L_x2->Visible = false;
- L_per2->Visible = false;
- L_x1->Visible = false;
- L_per1->Visible = false;
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- MessageBox::Show("RIVNANJA NE MAJE ROZVKAZKIV");
- return;
- }
- else if (D == 0)
- {
- L_per1->Visible = true;
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- x = (-b) / (2 * a);
- per = a*x*x + b*x + c;
- L_x1->Visible = true;
- L_x2->Visible = false;
- L_per2->Visible = false;
- L_x1->Text = "x1 = x2 = " + Convert::ToString(x);
- L_per1->Text = "в x = " + Convert::ToString(per);
- return;
- }
- else
- {
- x1 = (-b + Math::Sqrt(D)) / (2 * a);
- x2 = (-b - Math::Sqrt(D)) / (2 * a);
- per1 = a*x1*x1 + b*x1 + c;
- per2 = a*x2*x2 + b*x2 + c;
- L_x1->Visible = true;
- L_x1->Text = "x1 = " + Convert::ToString(x1);
- L_x2->Visible = true;
- L_x2->Text = "x2 = " + Convert::ToString(x2);
- L_per1->Visible = true;
- L_per2->Visible = true;
- L_D->Visible = true;
- L_D->Text = "D = " + Convert::ToString(D);
- L_per1->Text = "в x1 = " + Convert::ToString(per1);
- L_per2->Text = "в x2 = " + Convert::ToString(per2);
- return;
- }
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement