#pragma endregion
private: System::Void Sort(int *tab, int size)
{
int i,j,k;
for(i=1;i<size;i++)
{
j=i;
k=tab[j];
while((j>0) && (tab[j-1]>k))
{
tab[j]=tab[j-1];
j--;
}
tab[j]=k;
}
}
private: System::Double sum_double_Tab(double *tab, int size)
{
double sum;
sum=0.0;
for(int i=0;i<size;i++)
sum+=tab[i];
return sum;
}
private: System::Int64 sum_int_Tab(int *tab, int size)
{
int sum;
sum=0;
for(int i=0;i<size;i++)
sum+=tab[i];
return sum;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
srand(time(NULL));
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int i,j;
DataGridViewCellStyle^ grids_Style1=gcnew DataGridViewCellStyle();
DataGridViewCellStyle^ grids_Style2=gcnew DataGridViewCellStyle();
DataGridViewCellStyle^ grids_Style3=gcnew DataGridViewCellStyle();
System::Drawing::Font^ font_Grid1=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,16,FontStyle::Regular);
System::Drawing::Font^ font_Grid2=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,16,FontStyle::Underline);
System::Drawing::Font^ font_Grid3=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,16,FontStyle::Italic);
dataGridView2->ColumnCount=1;
dataGridView2->RowCount=5;
grids_Style2->Font=font_Grid2;
grids_Style2->ForeColor=System::Drawing::Color::Green;
dataGridView2->DefaultCellStyle=grids_Style2;
dataGridView2->DefaultCellStyle->BackColor=Color::Coral;
dataGridView2->Columns[0]->Width=95;
for(i=0;i<5;i++)
dataGridView2->Rows[i]->Height=30;
grids_Style2->Font=font_Grid2;
grids_Style2->ForeColor=System::Drawing::Color::Green;
dataGridView2->DefaultCellStyle=grids_Style2;
dataGridView2->Rows[0]->Cells[0]->Value="NUMBERS: ";
dataGridView2->Rows[1]->Cells[0]->Value="1/n";
dataGridView2->Rows[2]->Cells[0]->Value="sqrt(n)";
dataGridView2->Rows[3]->Cells[0]->Value="sin(n)";
dataGridView2->Rows[4]->Cells[0]->Value="cos(n)";
dataGridView1->ColumnCount=10;
dataGridView1->RowCount=5;
dataGridView1->DefaultCellStyle->BackColor=Color::Yellow;
dataGridView1->AlternatingRowsDefaultCellStyle->BackColor=Color::Red;
for(i=0;i<10;i++)
dataGridView1->Columns[i]->Width=90;
for(i=0;i<5;i++)
dataGridView1->Rows[i]->Height=30;
grids_Style1->Font=font_Grid1;
grids_Style1->ForeColor=System::Drawing::Color::Brown;
dataGridView1->DefaultCellStyle=grids_Style1;
int tab_Numbers[10];
double one_Tab[10],sqrt_Tab[10],sin_Tab[10],cos_Tab[10];
for(i=0;i<10;i++)
{
tab_Numbers[i]=rand()%360+1;
}
Sort(tab_Numbers,10);
for(i=0;i<10;i++)
{
one_Tab[i]=1./(double(tab_Numbers[i]*1.00));
sqrt_Tab[i]=sqrt(double(tab_Numbers[i]*1.00));
sin_Tab[i]=sin(double(tab_Numbers[i]*1.00));
cos_Tab[i]=cos(double(tab_Numbers[i]*1.00));
}
for(i=0;i<10;i++)
{
dataGridView1->Rows[0]->Cells[i]->Value=(tab_Numbers[i]).ToString();
dataGridView1->Rows[1]->Cells[i]->Value=one_Tab[i].ToString();
dataGridView1->Rows[2]->Cells[i]->Value=sqrt_Tab[i].ToString();
dataGridView1->Rows[3]->Cells[i]->Value=sin_Tab[i].ToString();
dataGridView1->Rows[4]->Cells[i]->Value=cos_Tab[i].ToString();
}
dataGridView3->ColumnCount=1;
dataGridView3->RowCount=5;
dataGridView3->DefaultCellStyle->BackColor=Color::BlueViolet;
dataGridView3->Columns[0]->Width=100;
for(i=0;i<5;i++)
dataGridView3->Rows[i]->Height=30;
grids_Style3->Font=font_Grid3;
grids_Style3->ForeColor=System::Drawing::Color::DarkOrange;
dataGridView3->DefaultCellStyle=grids_Style3;
int sum_Num;
double sum_One,sum_Sqrt,sum_Sin,sum_Cos;
sum_Num=sum_int_Tab(tab_Numbers,10);
sum_One=sum_double_Tab(one_Tab,10);
sum_Sqrt=sum_double_Tab(sqrt_Tab,10);
sum_Sin=sum_double_Tab(sin_Tab,10);
sum_Cos=sum_double_Tab(cos_Tab,10);
dataGridView3->Rows[0]->Cells[0]->Value=sum_Num.ToString();
dataGridView3->Rows[1]->Cells[0]->Value=sum_One.ToString();
dataGridView3->Rows[2]->Cells[0]->Value=sum_Sqrt.ToString();
dataGridView3->Rows[3]->Cells[0]->Value=sum_Sin.ToString();
dataGridView3->Rows[4]->Cells[0]->Value=sum_Cos.ToString();
}
};
}
private: System::Void Sort(int *tab, int size)
{
int i,j,k;
for(i=1;i<size;i++)
{
j=i;
k=tab[j];
while((j>0) && (tab[j-1]>k))
{
tab[j]=tab[j-1];
j--;
}
tab[j]=k;
}
}
private: System::Double sum_double_Tab(double *tab, int size)
{
double sum;
sum=0.0;
for(int i=0;i<size;i++)
sum+=tab[i];
return sum;
}
private: System::Int64 sum_int_Tab(int *tab, int size)
{
int sum;
sum=0;
for(int i=0;i<size;i++)
sum+=tab[i];
return sum;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
Close();
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
srand(time(NULL));
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
int i,j;
DataGridViewCellStyle^ grids_Style1=gcnew DataGridViewCellStyle();
DataGridViewCellStyle^ grids_Style2=gcnew DataGridViewCellStyle();
DataGridViewCellStyle^ grids_Style3=gcnew DataGridViewCellStyle();
System::Drawing::Font^ font_Grid1=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,16,FontStyle::Regular);
System::Drawing::Font^ font_Grid2=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,16,FontStyle::Underline);
System::Drawing::Font^ font_Grid3=gcnew System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,16,FontStyle::Italic);
dataGridView2->ColumnCount=1;
dataGridView2->RowCount=5;
grids_Style2->Font=font_Grid2;
grids_Style2->ForeColor=System::Drawing::Color::Green;
dataGridView2->DefaultCellStyle=grids_Style2;
dataGridView2->DefaultCellStyle->BackColor=Color::Coral;
dataGridView2->Columns[0]->Width=95;
for(i=0;i<5;i++)
dataGridView2->Rows[i]->Height=30;
grids_Style2->Font=font_Grid2;
grids_Style2->ForeColor=System::Drawing::Color::Green;
dataGridView2->DefaultCellStyle=grids_Style2;
dataGridView2->Rows[0]->Cells[0]->Value="NUMBERS: ";
dataGridView2->Rows[1]->Cells[0]->Value="1/n";
dataGridView2->Rows[2]->Cells[0]->Value="sqrt(n)";
dataGridView2->Rows[3]->Cells[0]->Value="sin(n)";
dataGridView2->Rows[4]->Cells[0]->Value="cos(n)";
dataGridView1->ColumnCount=10;
dataGridView1->RowCount=5;
dataGridView1->DefaultCellStyle->BackColor=Color::Yellow;
dataGridView1->AlternatingRowsDefaultCellStyle->BackColor=Color::Red;
for(i=0;i<10;i++)
dataGridView1->Columns[i]->Width=90;
for(i=0;i<5;i++)
dataGridView1->Rows[i]->Height=30;
grids_Style1->Font=font_Grid1;
grids_Style1->ForeColor=System::Drawing::Color::Brown;
dataGridView1->DefaultCellStyle=grids_Style1;
int tab_Numbers[10];
double one_Tab[10],sqrt_Tab[10],sin_Tab[10],cos_Tab[10];
for(i=0;i<10;i++)
{
tab_Numbers[i]=rand()%360+1;
}
Sort(tab_Numbers,10);
for(i=0;i<10;i++)
{
one_Tab[i]=1./(double(tab_Numbers[i]*1.00));
sqrt_Tab[i]=sqrt(double(tab_Numbers[i]*1.00));
sin_Tab[i]=sin(double(tab_Numbers[i]*1.00));
cos_Tab[i]=cos(double(tab_Numbers[i]*1.00));
}
for(i=0;i<10;i++)
{
dataGridView1->Rows[0]->Cells[i]->Value=(tab_Numbers[i]).ToString();
dataGridView1->Rows[1]->Cells[i]->Value=one_Tab[i].ToString();
dataGridView1->Rows[2]->Cells[i]->Value=sqrt_Tab[i].ToString();
dataGridView1->Rows[3]->Cells[i]->Value=sin_Tab[i].ToString();
dataGridView1->Rows[4]->Cells[i]->Value=cos_Tab[i].ToString();
}
dataGridView3->ColumnCount=1;
dataGridView3->RowCount=5;
dataGridView3->DefaultCellStyle->BackColor=Color::BlueViolet;
dataGridView3->Columns[0]->Width=100;
for(i=0;i<5;i++)
dataGridView3->Rows[i]->Height=30;
grids_Style3->Font=font_Grid3;
grids_Style3->ForeColor=System::Drawing::Color::DarkOrange;
dataGridView3->DefaultCellStyle=grids_Style3;
int sum_Num;
double sum_One,sum_Sqrt,sum_Sin,sum_Cos;
sum_Num=sum_int_Tab(tab_Numbers,10);
sum_One=sum_double_Tab(one_Tab,10);
sum_Sqrt=sum_double_Tab(sqrt_Tab,10);
sum_Sin=sum_double_Tab(sin_Tab,10);
sum_Cos=sum_double_Tab(cos_Tab,10);
dataGridView3->Rows[0]->Cells[0]->Value=sum_Num.ToString();
dataGridView3->Rows[1]->Cells[0]->Value=sum_One.ToString();
dataGridView3->Rows[2]->Cells[0]->Value=sum_Sqrt.ToString();
dataGridView3->Rows[3]->Cells[0]->Value=sum_Sin.ToString();
dataGridView3->Rows[4]->Cells[0]->Value=sum_Cos.ToString();
}
};
}
YOU CAN PAY ME - https://paypal.me/LukaszW77?locale.x=pl_PL
Brak komentarzy:
Prześlij komentarz