AddO1f

LabF3

Apr 3rd, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #pragma once
  2. #include <math.h>
  3.  
  4. #pragma endregion
  5. private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  6.             double xn,xk,xh,x,y,a,ymax,ymin,yt;
  7.             int n,i;
  8.             if ((textBox1->Text!="")&&(textBox2->Text!="")&& (textBox3->Text!="")&&(textBox4->Text!=""))
  9.             {
  10.                 xn = Convert::ToDouble(textBox1->Text);
  11.                 xk = Convert::ToDouble(textBox2->Text);
  12.                 xh = Convert::ToDouble(textBox3->Text);
  13.                 a =  Convert::ToDouble(textBox4->Text);
  14.                 int k =0;
  15.                 k = dataGridView1->ColumnCount;
  16.                 if (k != 0)
  17.                 for (int i = 0; i < k; i++)  
  18.                 dataGridView1->Columns->Clear();
  19.                 dataGridView1->ColumnCount = 2;
  20.                 dataGridView1->Rows->Add(ceil((xk-xn)/xh)+1);
  21.                 dataGridView1->Rows[0]->Cells[0]->Value =Convert::ToString("      x");
  22.                 dataGridView1->Rows[0]->Cells[1]->Value =Convert::ToString("      Y");
  23.                 i=1;
  24.                 x=xn;
  25.                 ymax=-1.8e307;ymin=1.8e307;
  26.                 while (x<=xk)  
  27.                 {
  28.                     if (x<=0){y=pow(sin(pow(x,3)),2);}
  29.                     else  
  30.                     if (x<=a) {y=pow(6*x-x*x-1,0.2);}
  31.                     else  
  32.                     if (x>a) {y=sin(x-exp(-x));}
  33.                     dataGridView1->Rows[i]->Cells[0]->Value =Convert::ToString(x);
  34.                     yt=ceil(y*100)/100;  
  35.                     dataGridView1->Rows[i]->Cells[1]->Value =Convert::ToString(yt);  
  36.                     if (y>ymax) ymax=ceil(y*100)/100;
  37.                     if (y<ymin) ymin=ceil(y*100)/100;
  38.                     x=x+xh;  
  39.                     i++;
  40.                 }
  41.                 textBox5->Text = Convert::ToString (ymax);
  42.                 textBox6->Text = Convert::ToString (ymin);
  43.             }
  44.             else {MessageBox::Show( "Заполните данные", "Ошибка ввода", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );}
  45.         }
  46. };
  47. }
Advertisement
Add Comment
Please, Sign In to add comment