Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #pragma once
- void create_table(double begin, double end, double gap);
- namespace Knopka_lab6 {
- 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>
- /// Сводка для Form1
- /// </summary>
- public ref class Form1 : public System::Windows::Forms::Form
- {
- public:
- Form1(void)
- {
- InitializeComponent();
- //
- //TODO: добавьте код конструктора
- //
- }
- protected:
- /// <summary>
- /// Освободить все используемые ресурсы.
- /// </summary>
- ~Form1()
- {
- if (components)
- {
- delete components;
- }
- }
- private: System::Windows::Forms::ListBox^ listBox1;
- protected:
- 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::TextBox^ textBox1;
- private: System::Windows::Forms::TextBox^ textBox2;
- private: System::Windows::Forms::TextBox^ textBox3;
- private: System::Windows::Forms::Button^ button1;
- private:
- /// <summary>
- /// Требуется переменная конструктора.
- /// </summary>
- System::ComponentModel::Container ^components;
- #pragma region Windows Form Designer generated code
- /// <summary>
- /// Обязательный метод для поддержки конструктора - не изменяйте
- /// содержимое данного метода при помощи редактора кода.
- /// </summary>
- void InitializeComponent(void)
- {
- this->listBox1 = (gcnew System::Windows::Forms::ListBox());
- 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->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->SuspendLayout();
- //
- // listBox1
- //
- this->listBox1->FormattingEnabled = true;
- this->listBox1->Location = System::Drawing::Point(12, 61);
- this->listBox1->Name = L"listBox1";
- this->listBox1->Size = System::Drawing::Size(262, 329);
- this->listBox1->TabIndex = 0;
- //
- // label1
- //
- this->label1->AutoSize = true;
- this->label1->Location = System::Drawing::Point(85, 23);
- this->label1->Name = L"label1";
- this->label1->Size = System::Drawing::Size(50, 13);
- this->label1->TabIndex = 1;
- this->label1->Text = L"Таблица";
- //
- // label2
- //
- this->label2->AutoSize = true;
- this->label2->Location = System::Drawing::Point(280, 61);
- this->label2->Name = L"label2";
- this->label2->Size = System::Drawing::Size(199, 13);
- this->label2->TabIndex = 2;
- this->label2->Text = L"Введите начальное значение отрезка";
- //
- // label3
- //
- this->label3->AutoSize = true;
- this->label3->Location = System::Drawing::Point(280, 129);
- this->label3->Name = L"label3";
- this->label3->Size = System::Drawing::Size(193, 13);
- this->label3->TabIndex = 3;
- this->label3->Text = L"Введите конечное значение отрезка";
- //
- // label4
- //
- this->label4->AutoSize = true;
- this->label4->Location = System::Drawing::Point(280, 194);
- this->label4->Name = L"label4";
- this->label4->Size = System::Drawing::Size(71, 13);
- this->label4->TabIndex = 4;
- this->label4->Text = L"Введите шаг";
- //
- // textBox1
- //
- this->textBox1->Location = System::Drawing::Point(280, 77);
- this->textBox1->Name = L"textBox1";
- this->textBox1->Size = System::Drawing::Size(199, 20);
- this->textBox1->TabIndex = 5;
- //
- // textBox2
- //
- this->textBox2->Location = System::Drawing::Point(280, 145);
- this->textBox2->Name = L"textBox2";
- this->textBox2->Size = System::Drawing::Size(193, 20);
- this->textBox2->TabIndex = 6;
- //
- // textBox3
- //
- this->textBox3->Location = System::Drawing::Point(280, 210);
- this->textBox3->Name = L"textBox3";
- this->textBox3->Size = System::Drawing::Size(100, 20);
- this->textBox3->TabIndex = 7;
- //
- // button1
- //
- this->button1->Location = System::Drawing::Point(311, 358);
- this->button1->Name = L"button1";
- this->button1->Size = System::Drawing::Size(75, 23);
- this->button1->TabIndex = 8;
- this->button1->Text = L"Оk";
- this->button1->UseVisualStyleBackColor = true;
- this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
- //
- // Form1
- //
- this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
- this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
- this->ClientSize = System::Drawing::Size(539, 405);
- this->Controls->Add(this->button1);
- this->Controls->Add(this->textBox3);
- this->Controls->Add(this->textBox2);
- this->Controls->Add(this->textBox1);
- this->Controls->Add(this->label4);
- this->Controls->Add(this->label3);
- this->Controls->Add(this->label2);
- this->Controls->Add(this->label1);
- this->Controls->Add(this->listBox1);
- this->Name = L"Form1";
- this->Text = L"Form1";
- this->ResumeLayout(false);
- this->PerformLayout();
- }
- #pragma endregion
- double schet(double x)
- {
- double y;
- y = pow(x,8)-0.4*pow(x,3)-1.24;
- return y;
- }
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- double nach , kon, shag;
- nach = Convert::ToDouble(textBox1->Text);
- kon = Convert::ToDouble(textBox2->Text);
- shag = Convert::ToDouble(textBox3->Text);
- tabliza(nach,kon,shag);
- }
- void tabliza(double nach, double kon, double shag){
- double proizved=1;
- double y;
- double itercount = (kon-nach)/shag;
- for (int i=1;i<=itercount;i++)
- {
- y=schet(nach);
- if(y<0)
- proizved=proizved*y;
- listBox1->Items->Add(String::Format("f({0}) = {1}",nach,y));
- nach=nach+shag;
- }
- listBox1->Items->Add(String::Format("Произведение {0}",proizved));
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement