In the File:
using namespace System::IO;
#pragma endregion
private:
int *table_first,*sum_t,*sum_max;
float *ms_sum,*ms_first;
private:
System::Boolean is_First(System::Int16 Value)
{
System::Int16 i;
System::Int16 sum;
for(i=1;i<Value+1;i++)
if(Value%i==0)
++sum;
if(sum==2)
return true;
else
return false;
}
private:
System::Void init_Table()
{
System::Int16 i;
System::Int16 j;
System::Int16 k;
System::Int16 sum;
i=0;
j=2;
do
{
if(is_First(j))
{
sum=0;
table_first[i]=j;
sum_t[i]=sum_Table(table_first,i+1);
for(k=1;k<j+1;k++)
sum+=k;
sum_max[i]=sum;
ms_sum[i]=(1.0*sum_max[i])/(sum_t[i]*1.0);
ms_first[i]=(1.0*sum_t[i])/(1.0*table_first[i]);
++i;
}
++j;
}while(i<50);
}
private:
System::Int16 sum_Table(int *table, System::Int16 size)
{
System::Int16 i;
System::Int16 sum;
sum=0;
for(i=0;i<size;i++)
sum+=table[i];
return sum;
}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
delete ms_sum;
delete ms_first;
delete table_first;
delete sum_max;
delete sum_t;
Close();
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
table_first=new int[50];
sum_max=new int[50];
sum_t=new int[50];
ms_sum=new float[50];
ms_first=new float[50];
init_Table();
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
System::Int16 i;
System::Int16 sum;
listBox1->Items->Clear();
listBox2->Items->Clear();
listBox3->Items->Clear();
listBox4->Items->Clear();
listBox5->Items->Clear();
for(i=0;i<50;i++)
{
listBox1->Items->Add(table_first[i].ToString());
listBox2->Items->Add(sum_t[i].ToString());
listBox3->Items->Add(sum_max[i].ToString());
listBox4->Items->Add(ms_sum[i].ToString());
listBox5->Items->Add(ms_first[i].ToString());
}
StreamWriter^ mFile=gcnew StreamWriter("mFile.txt",0,System::Text::Encoding::Default);
for(i=0;i<50;i++)
{
mFile->WriteLine(table_first[i].ToString());
mFile->WriteLine(sum_t[i].ToString());
mFile->WriteLine(sum_max[i].ToString());
mFile->WriteLine(ms_sum[i].ToString());
mFile->WriteLine(ms_first[i].ToString());
}
mFile->Close();
}
};
}
Brak komentarzy:
Prześlij komentarz