Advertisement
Guest User

Untitled

a guest
May 25th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.44 KB | None | 0 0
  1. #include <math.h>
  2. #pragma once
  3. void create_table(double begin, double end, double gap);
  4. namespace Knopka_lab6 {
  5.  
  6.     using namespace System;
  7.     using namespace System::ComponentModel;
  8.     using namespace System::Collections;
  9.     using namespace System::Windows::Forms;
  10.     using namespace System::Data;
  11.     using namespace System::Drawing;
  12.  
  13.     /// <summary>
  14.     /// Сводка для Form1
  15.     /// </summary>
  16.     public ref class Form1 : public System::Windows::Forms::Form
  17.     {
  18.     public:
  19.         Form1(void)
  20.         {
  21.             InitializeComponent();
  22.             //
  23.             //TODO: добавьте код конструктора
  24.             //
  25.         }
  26.  
  27.     protected:
  28.         /// <summary>
  29.         /// Освободить все используемые ресурсы.
  30.         /// </summary>
  31.         ~Form1()
  32.         {
  33.             if (components)
  34.             {
  35.                 delete components;
  36.             }
  37.         }
  38.     private: System::Windows::Forms::ListBox^  listBox1;
  39.     protected:
  40.     private: System::Windows::Forms::Label^  label1;
  41.     private: System::Windows::Forms::Label^  label2;
  42.     private: System::Windows::Forms::Label^  label3;
  43.     private: System::Windows::Forms::Label^  label4;
  44.     private: System::Windows::Forms::TextBox^  textBox1;
  45.     private: System::Windows::Forms::TextBox^  textBox2;
  46.     private: System::Windows::Forms::TextBox^  textBox3;
  47.     private: System::Windows::Forms::Button^  button1;
  48.  
  49.     private:
  50.         /// <summary>
  51.         /// Требуется переменная конструктора.
  52.         /// </summary>
  53.         System::ComponentModel::Container ^components;
  54.  
  55. #pragma region Windows Form Designer generated code
  56.         /// <summary>
  57.         /// Обязательный метод для поддержки конструктора - не изменяйте
  58.         /// содержимое данного метода при помощи редактора кода.
  59.         /// </summary>
  60.         void InitializeComponent(void)
  61.         {
  62.             this->listBox1 = (gcnew System::Windows::Forms::ListBox());
  63.             this->label1 = (gcnew System::Windows::Forms::Label());
  64.             this->label2 = (gcnew System::Windows::Forms::Label());
  65.             this->label3 = (gcnew System::Windows::Forms::Label());
  66.             this->label4 = (gcnew System::Windows::Forms::Label());
  67.             this->textBox1 = (gcnew System::Windows::Forms::TextBox());
  68.             this->textBox2 = (gcnew System::Windows::Forms::TextBox());
  69.             this->textBox3 = (gcnew System::Windows::Forms::TextBox());
  70.             this->button1 = (gcnew System::Windows::Forms::Button());
  71.             this->SuspendLayout();
  72.             //
  73.             // listBox1
  74.             //
  75.             this->listBox1->FormattingEnabled = true;
  76.             this->listBox1->Location = System::Drawing::Point(12, 61);
  77.             this->listBox1->Name = L"listBox1";
  78.             this->listBox1->Size = System::Drawing::Size(262, 329);
  79.             this->listBox1->TabIndex = 0;
  80.             //
  81.             // label1
  82.             //
  83.             this->label1->AutoSize = true;
  84.             this->label1->Location = System::Drawing::Point(85, 23);
  85.             this->label1->Name = L"label1";
  86.             this->label1->Size = System::Drawing::Size(50, 13);
  87.             this->label1->TabIndex = 1;
  88.             this->label1->Text = L"Таблица";
  89.             //
  90.             // label2
  91.             //
  92.             this->label2->AutoSize = true;
  93.             this->label2->Location = System::Drawing::Point(280, 61);
  94.             this->label2->Name = L"label2";
  95.             this->label2->Size = System::Drawing::Size(199, 13);
  96.             this->label2->TabIndex = 2;
  97.             this->label2->Text = L"Введите начальное значение отрезка";
  98.             //
  99.             // label3
  100.             //
  101.             this->label3->AutoSize = true;
  102.             this->label3->Location = System::Drawing::Point(280, 129);
  103.             this->label3->Name = L"label3";
  104.             this->label3->Size = System::Drawing::Size(193, 13);
  105.             this->label3->TabIndex = 3;
  106.             this->label3->Text = L"Введите конечное значение отрезка";
  107.             //
  108.             // label4
  109.             //
  110.             this->label4->AutoSize = true;
  111.             this->label4->Location = System::Drawing::Point(280, 194);
  112.             this->label4->Name = L"label4";
  113.             this->label4->Size = System::Drawing::Size(71, 13);
  114.             this->label4->TabIndex = 4;
  115.             this->label4->Text = L"Введите шаг";
  116.             //
  117.             // textBox1
  118.             //
  119.             this->textBox1->Location = System::Drawing::Point(280, 77);
  120.             this->textBox1->Name = L"textBox1";
  121.             this->textBox1->Size = System::Drawing::Size(199, 20);
  122.             this->textBox1->TabIndex = 5;
  123.             //
  124.             // textBox2
  125.             //
  126.             this->textBox2->Location = System::Drawing::Point(280, 145);
  127.             this->textBox2->Name = L"textBox2";
  128.             this->textBox2->Size = System::Drawing::Size(193, 20);
  129.             this->textBox2->TabIndex = 6;
  130.             //
  131.             // textBox3
  132.             //
  133.             this->textBox3->Location = System::Drawing::Point(280, 210);
  134.             this->textBox3->Name = L"textBox3";
  135.             this->textBox3->Size = System::Drawing::Size(100, 20);
  136.             this->textBox3->TabIndex = 7;
  137.             //
  138.             // button1
  139.             //
  140.             this->button1->Location = System::Drawing::Point(311, 358);
  141.             this->button1->Name = L"button1";
  142.             this->button1->Size = System::Drawing::Size(75, 23);
  143.             this->button1->TabIndex = 8;
  144.             this->button1->Text = L"Оk";
  145.             this->button1->UseVisualStyleBackColor = true;
  146.             this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
  147.             //
  148.             // Form1
  149.             //
  150.             this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
  151.             this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
  152.             this->ClientSize = System::Drawing::Size(539, 405);
  153.             this->Controls->Add(this->button1);
  154.             this->Controls->Add(this->textBox3);
  155.             this->Controls->Add(this->textBox2);
  156.             this->Controls->Add(this->textBox1);
  157.             this->Controls->Add(this->label4);
  158.             this->Controls->Add(this->label3);
  159.             this->Controls->Add(this->label2);
  160.             this->Controls->Add(this->label1);
  161.             this->Controls->Add(this->listBox1);
  162.             this->Name = L"Form1";
  163.             this->Text = L"Form1";
  164.             this->ResumeLayout(false);
  165.             this->PerformLayout();
  166.  
  167.         }
  168. #pragma endregion
  169. double schet(double x)
  170. {
  171.     double y;
  172.         y = pow(x,8)-0.4*pow(x,3)-1.24;
  173.     return y;
  174.  
  175. }
  176.     private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  177.                 double nach , kon, shag;
  178.                 nach = Convert::ToDouble(textBox1->Text);
  179.                 kon = Convert::ToDouble(textBox2->Text);
  180.                 shag = Convert::ToDouble(textBox3->Text);
  181.                 tabliza(nach,kon,shag);
  182.              }
  183.              void tabliza(double nach, double kon, double shag){
  184.                 double proizved=1;
  185.                 double y;
  186.                 double itercount = (kon-nach)/shag;
  187.                 for (int i=1;i<=itercount;i++)
  188.                 {
  189.                     y=schet(nach);
  190.                     if(y<0)
  191.                         proizved=proizved*y;
  192.                     listBox1->Items->Add(String::Format("f({0}) = {1}",nach,y));
  193.                     nach=nach+shag;
  194.                 }
  195.                 listBox1->Items->Add(String::Format("Произведение {0}",proizved));
  196.              }
  197. };
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement