#pragma endregion
private: int **my_Bet;
private: int *Lotto;
private: System::Void Sort(int *table, int size)
{
int i,j,temp;
for(i=1;i<size;i++)
for(j=size-1;j>=i;j--)
if(table[j]<table[j-1])
{
temp=table[j-1];
table[j-1]=table[j];
table[j]=temp;
}
}
private: System::Void init_Table()
{
int i;
my_Bet=new int*[1000];
for(i=0;i<1000;i++)
my_Bet[i]=new int[6];
Lotto=new int[6];
}
private: System::Void delete_Table()
{
int i;
for(i=0;i<1000;i++)
delete [] my_Bet[i];
delete [] *my_Bet;
delete Lotto;
}
private: System::Boolean is_Six(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==6)
return true;
else
return false;
}
private: System::Boolean is_Five(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==5)
return true;
else
return false;
}
private: System::Boolean is_Four(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==4)
return true;
else
return false;
}
private: System::Boolean is_Three(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==3)
return true;
else
return false;
}
private: System::Boolean is_Two(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==2)
return true;
else
return false;
}
private: System::Boolean is_One(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==1)
return true;
else
return false;
}
private: System::Boolean is_Zero(int *tab1, int *tab2,int size)
{
int i,j,value;
value=0;
i=0;
do
{
for(j=0;j<size;j++)
if(tab1[i]==tab2[j])
++value;
++i;
}while(i<size);
if(value==0)
return true;
else
return false;
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
srand(time(NULL));
init_Table();
dataGridView1->RowCount=1;
dataGridView1->ColumnCount=6;
dataGridView1->Rows[0]->Height=30;
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
DataGridViewCellStyle^ my_Style=gcnew DataGridViewCellStyle();
System::Drawing::Font^ my_Font=gcnew
System::Drawing::Font(System::Drawing::FontFamily::GenericSansSerif,22,FontStyle::Regular);
my_Style->Font=my_Font;
dataGridView1->Rows[0]->DefaultCellStyle->BackColor=System::Drawing::Color::YellowGreen;
listBox1->Items->Clear();
int i,j,k,value;
int *temp_Lotto,**temp_Bet;
temp_Lotto=new int[49];
temp_Bet=new int*[1000];
for(i=0;i<1000;i++)
temp_Bet[i]=new int[49];
for(i=0;i<49;i++)
temp_Lotto[i]=0;
for(i=0;i<1000;i++)
for(j=0;j<49;j++)
temp_Bet[i][j]=0;
i=0;
do
{
do
{
value=rand()%49;
} while(temp_Lotto[value]!=0);
temp_Lotto[value]=1;
Lotto[i]=value+1;
++i;
}while(i<6);
i=0;
do
{
j=0;
do
{
do
{
value=rand()%49;
}while(temp_Bet[i][value]!=0);
temp_Bet[i][value]=1;
my_Bet[i][j]=value+1;
++j;
}while(j<6);
++i;
}while(i<1000);
Sort(Lotto,6);
for(i=0;i<1000;i++)
Sort(my_Bet[i],6);
for(i=0;i<6;i++)
dataGridView1->Rows[0]->Cells[i]->Value=Lotto[i].ToString();
for(i=0;i<1000;i++)
for(i=0;i<1000;i++)
{
listBox1->Items->Add((i+1).ToString()+") "+my_Bet[i][0].ToString()+","+my_Bet[i][1].ToString()+","+my_Bet[i][2].ToString()+
","+my_Bet[i][3].ToString()+","+my_Bet[i][4].ToString()+","+my_Bet[i][5].ToString());
}
int a0,a1,a2,a3,a4,a5,a6;
a0=a1=a2=a3=a4=a5=a6=0;
for(i=0;i<1000;i++)
{
if(is_Zero(my_Bet[i],Lotto,6))
++a0;
if(is_One(my_Bet[i],Lotto,6))
++a1;
if(is_Two(my_Bet[i],Lotto,6))
++a2;
if(is_Three(my_Bet[i],Lotto,6))
++a3;
if(is_Four(my_Bet[i],Lotto,6))
++a4;
if(is_Five(my_Bet[i],Lotto,6))
++a5;
if(is_Six(my_Bet[i],Lotto,6))
++a6;
}
textBox1->Text=a6.ToString();
textBox2->Text=a5.ToString();
textBox3->Text=a4.ToString();
textBox4->Text=a3.ToString();
textBox5->Text=a2.ToString();
textBox6->Text=a1.ToString();
textBox7->Text=a0.ToString();
delete [] temp_Bet[i];
delete [] *temp_Bet;
delete temp_Lotto;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
delete_Table();
Close();
}
};
}