Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <math.h>
- #pragma endregion
- private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
- double xn,xk,xh,x,y,a,ymax,ymin,yt;
- int n,i;
- if ((textBox1->Text!="")&&(textBox2->Text!="")&& (textBox3->Text!="")&&(textBox4->Text!=""))
- {
- xn = Convert::ToDouble(textBox1->Text);
- xk = Convert::ToDouble(textBox2->Text);
- xh = Convert::ToDouble(textBox3->Text);
- a = Convert::ToDouble(textBox4->Text);
- int k =0;
- k = dataGridView1->ColumnCount;
- if (k != 0)
- for (int i = 0; i < k; i++)
- dataGridView1->Columns->Clear();
- dataGridView1->ColumnCount = 2;
- dataGridView1->Rows->Add(ceil((xk-xn)/xh)+1);
- dataGridView1->Rows[0]->Cells[0]->Value =Convert::ToString(" x");
- dataGridView1->Rows[0]->Cells[1]->Value =Convert::ToString(" Y");
- i=1;
- x=xn;
- ymax=-1.8e307;ymin=1.8e307;
- while (x<=xk)
- {
- if (x<=0){y=pow(sin(pow(x,3)),2);}
- else
- if (x<=a) {y=pow(6*x-x*x-1,0.2);}
- else
- if (x>a) {y=sin(x-exp(-x));}
- dataGridView1->Rows[i]->Cells[0]->Value =Convert::ToString(x);
- yt=ceil(y*100)/100;
- dataGridView1->Rows[i]->Cells[1]->Value =Convert::ToString(yt);
- if (y>ymax) ymax=ceil(y*100)/100;
- if (y<ymin) ymin=ceil(y*100)/100;
- x=x+xh;
- i++;
- }
- textBox5->Text = Convert::ToString (ymax);
- textBox6->Text = Convert::ToString (ymin);
- }
- else {MessageBox::Show( "Заполните данные", "Ошибка ввода", MessageBoxButtons::OK, MessageBoxIcon::Exclamation );}
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment