#pragma endregion
 private:
  System::Void Sorting(array<System::Int32>^table, int size)
  {
   int i,j,temp;
   for(i=1;i<size;i++)
   {
    j=i;
    temp=table[j];
    while((j>0) && (table[j-1]>temp))
    {
     table[j]=table[j-1];
     j--;
    }
    table[j]=temp;
   }
  }
  private:
   array<System::Int32>^dateX;
  private:
   array<System::Int32>^dateY;
  private:
   array<System::Drawing::PointF>^points;
 private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
     dataGridView1->ColumnCount=2;
     dataGridView1->RowCount=50;
     int i;
     for(i=0;i<2;i++)
      dataGridView1->Columns[i]->Width=40;
     for(i=0;i<50;i++)
      dataGridView1->Rows[i]->Height=14;
     srand(time(NULL));
     points=gcnew array<System::Drawing::PointF>(50);
     dateX=gcnew array<System::Int32>(50);
     dateY=gcnew array<System::Int32>(50);
    }
 private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
     Close();
    }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
    int i;
    Graphics^ graph=panel1->CreateGraphics();
    System::Drawing::Color temp_Color;
    for(i=0;i<50;i++)
    {
     dateX[i]=rand()%panel1->Width;
     dateY[i]=rand()%panel1->Height;
    }
    Sorting(dateX,50);
    for(i=0;i<50;i++)
    {
     dataGridView1->Rows[i]->Cells[0]->Value=dateX[i];
     dataGridView1->Rows[i]->Cells[1]->Value=dateY[i];
     points[i].X=dateX[i];
     points[i].Y=dateY[i];
    }
    dataGridView1->AutoResizeRows();
    for(i=0;i<50;i++)
    {
     int r_color,g_color,b_color;
     r_color=rand()%255;
     g_color=rand()%255;
     b_color=rand()%255;
     temp_Color=System::Drawing::Color::FromArgb(r_color,g_color,b_color);
     Pen^ temp_Pen=gcnew Pen(temp_Color);
     graph->DrawCurve(temp_Pen,points);
    }
   }
};
}

Brak komentarzy:
Prześlij komentarz