piątek, 6 września 2019

A simple chart (Visual C++)



#pragma endregion
System::Boolean is_First(int value)
{
int i,sum=0;
for(i=1;i<value+1;i++)
if(value%i==0)
++sum;
if(sum==2)
return true;
else
return false;
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Close();
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
Graphics^ gr=panel1->CreateGraphics();
Pen^ pn=gcnew Pen(System::Drawing::Color::Blue);
int height=panel1->Height;
int *tab;
int how_many=0;
int i,j;
int width=panel1->Width;
pn->Width=2;
int x0=0,y0=0,x1,y1=0;
for(i=0;i<width;i++)
{
                  if(is_First(i))
 {
++how_many;
 }
}
tab=new int[how_many];
i=0;
j=2;
do
{
if(is_First(j))
{
tab[i]=j;
++i;
}
++j;
}while(i<how_many);
for(i=0;i<how_many-1;i++)
{
                   gr->DrawLine(pn,tab[i],height,tab[i+1],height);
  height-=2;
}

delete tab;

label1->Text=panel1->Width.ToString();
label2->Text="0";



}
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
};
}


Brak komentarzy:

Prześlij komentarz