sobota, 26 sierpnia 2017

Transormations prime number and others (Visual C++)





#pragma endregion
System::Boolean is_First(int value)
{
int i,sum;
sum=0;
for(i=1;i<value+1;i++)
if(value%i==0)
++sum;
if(sum==2)
return true;
else
return false;
}
System::Void init_Array(int *table, int size)
{
int i,j;
i=0;
j=2;
do
{
              if(is_First(j))
 {
 table[i]=j;
 ++i;
 }
 ++j;
}while(i<size);
}
System::Int32 sum_Table(int *table, int size)
{
int i,sum;
sum=0;
for(i=0;i<size;i++)
sum+=table[i];
return sum;
}
System::Int32 multiplication_Table(int *table, int size)
{
int i,multi;
multi=1;
for(i=0;i<size;i++)
multi*=table[i];
return multi;
}
System::Double multi_div_sum_Table(int *table, int size)
{
int i;
double value;
value=(1.*multiplication_Table(table,size))/(1.*sum_Table(table,size));
return value;
}

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Close();
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
int first_Table[9],sum_Tab[9],multi_Tab[9],not_first_Table[9],sum_not_first_Table[9],
multi_not_first_Table[9],diff_first[8],diff_not_first[8],diff_first_sum[8],diff_not_first_sum[8],
diff_first_mul[8],diff_not_first_mul[8];
double mul_dev_sum[9],mul_not_dev_sum[9],diff_mul_dev_first[8],diff_not_mul_dev[8];
int first_plus_not[9],not_plus_first[9],sum_div_first[9],sum_div_not_first[9];
double value_mal_first_div[9],value_mal_not_first_div[9];
int i,j;
init_Array(first_Table,9);
i=0;
j=1;

do
{
               if(!is_First(j))
  {
  not_first_Table[i]=j;
  ++i;
  }
  ++j;

}while(i<9);
for(i=0;i<9;i++)
{
listBox1->Items->Add(first_Table[i].ToString());
sum_Tab[i]=sum_Table(first_Table,i+1);
listBox2->Items->Add(sum_Tab[i].ToString());
multi_Tab[i]=multiplication_Table(first_Table,i+1);
listBox3->Items->Add(multi_Tab[i].ToString());
                 mul_dev_sum[i]=multi_div_sum_Table(first_Table,i+1);
listBox4->Items->Add(mul_dev_sum[i].ToString());
listBox5->Items->Add(not_first_Table[i].ToString());
sum_not_first_Table[i]=sum_Table(not_first_Table,i+1);
listBox6->Items->Add(sum_not_first_Table[i].ToString());
multi_not_first_Table[i]=multiplication_Table(not_first_Table,i+1);
listBox7->Items->Add(multi_not_first_Table[i].ToString());
mul_not_dev_sum[i]=multi_div_sum_Table(not_first_Table,i+1);
listBox8->Items->Add(mul_not_dev_sum[i].ToString());
 
}
for(i=0,j=1;i<8;i++,j++)
{
                diff_first[i]=first_Table[j]-first_Table[i];
                diff_not_first[i]=not_first_Table[j]-not_first_Table[i];
listBox9->Items->Add(diff_first[i].ToString());
listBox10->Items->Add(diff_not_first[i].ToString());
diff_first_sum[i]=sum_Tab[j]-sum_not_first_Table[i];
listBox11->Items->Add(diff_first_sum[i].ToString());
   diff_not_first_sum[i]=sum_not_first_Table[j]-sum_Tab[i];
listBox12->Items->Add(diff_not_first_sum[i].ToString());
diff_first_mul[i]=multi_Tab[j]- multi_not_first_Table[i];
listBox13->Items->Add(diff_first_mul[i].ToString());
diff_not_first_mul[i]=multi_not_first_Table[j]-multi_Tab[i];
listBox14->Items->Add(diff_not_first_mul[i].ToString());
diff_mul_dev_first[i]=mul_dev_sum[j]-mul_not_dev_sum[i];
listBox15->Items->Add(diff_mul_dev_first[i].ToString());
diff_not_mul_dev[i]=mul_not_dev_sum[j]-=mul_dev_sum[j];
listBox16->Items->Add(diff_not_mul_dev[i].ToString());


               
}
first_plus_not[0]=first_Table[0];
not_plus_first[0]=not_first_Table[0];
for(i=1,j=0;i<9;i++,j++)
{
first_plus_not[i]=first_Table[i]+diff_not_first_sum[j];
not_plus_first[i]=not_first_Table[i]+diff_first_sum[j];
}
for(i=0;i<9;i++)
{
listBox17->Items->Add(first_plus_not[i].ToString());
listBox18->Items->Add(not_plus_first[i].ToString());
sum_div_first[i]=(1.*sum_Tab[i])/(1.*first_Table[i]);
listBox19->Items->Add(sum_div_first[i].ToString());
sum_div_not_first[i]=(1.*sum_not_first_Table[i])/(1.*not_first_Table[i]);
listBox20->Items->Add(sum_div_not_first[i].ToString());
value_mal_first_div[i]=(1.*multi_Tab[i])/(1.*sum_Tab[i]*first_Table[i]);
listBox21->Items->Add(value_mal_first_div[i].ToString());
value_mal_not_first_div[i]=(1.* multi_not_first_Table[i])/(1.*sum_not_first_Table[i]*not_first_Table[i]);
listBox22->Items->Add(value_mal_not_first_div[i].ToString());
}
int only_first_in_First[9],only_not_first_in_not_First[9];
for(i=0;i<9;i++)
{
               only_first_in_First[i]=0;
  only_not_first_in_not_First[i]=0;

}

i=0;
 
do
{
               j=1;
  do
  {
                if(is_First(j))
{
only_first_in_First[i]+=j;
}
++j;
  }while(j<first_Table[i]);
  ++i;
}while(i<9);

i=0;

do
{
j=1;
do
{
if(!is_First(j))
{
                       only_not_first_in_not_First[i]+=j;
}
++j;
}while(j<not_first_Table[i]);
++i;
}while(i<9);
for(i=0;i<9;i++)
{
listBox23->Items->Add(only_first_in_First[i].ToString());
listBox24->Items->Add(only_not_first_in_not_First[i].ToString());
}
}
};
}

Brak komentarzy:

Prześlij komentarz