mas[l-2]*de*pow(2,n-c+2)+mas[l-1]*de*pow(2,n-c+1)+mas[l]*de*pow(2,n-c);
x6=un;
}
if (uvh>un)
;
if (uvh==un)
mas[l]=1;
if (uvh<un)
mas[l]=0;
Label11->Caption = Label11->Caption + IntToStr(mas[l]) + " " ;
l++;
mas1[l1]=1;
c1++;
for (i=c1;i<n;i++)
mas1[i]=0;
if (l1==0)
{
un1=mas1[l1]*de*pow(2,n-c1);
x11=un1;
}
if (l1==1)
{
un1=mas1[l1-1]*de*pow(2,n-c1+1)+mas1[l1]*de*pow(2,n-c1);
x21=un1;
}
if (l1==2)
{
un1=mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x31=un1;
}
if (l1==3)
{
un1=mas1[l1-3]*de*pow(2,n-c1+3)+mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x41=un1;
}
if (l1==4)
{
un1=mas1[l1-4]*de*pow(2,n-c1+4)+mas1[l1-3]*de*pow(2,n-c1+3)+mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x51=un1;
}
if (l1==5)
{
un1=mas1[l1-5]*de*pow(2,n-c1+5)+mas1[l1-4]*de*pow(2,n-c1+4)+mas1[l1-3]*de*pow(2,n-c1+3)+mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x61=un1;
}
if (uvh>un1)
mas1[l1]=1;
if (uvh==un1)
mas1[l1]=0;
if (uvh<un1)
mas1[l1]=0;
Label12->Caption = Label12->Caption + IntToStr(mas1[l1]) + " " ;
l1++;
}
while (l!=n);
float map=0;
float mvp=0;
float skap=0;
float skvp=0;
map=de/2;
Edit5->Text=FloatToStrF(map,ffFixed,2,2);
mvp=100/(pow(2,n+1));
Edit6->Text=FloatToStrF(mvp,ffFixed,2,2);
skap=de/(pow(3,0.5)*2);
Edit8->Text=FloatToStrF(skap,ffFixed,2,2);
skvp=100/(pow(3,0.5)*pow(2,n+1));
Edit7->Text=FloatToStrF(skvp,ffFixed,2,2);
float tp=0;
tp=n*t;
Label13->Caption=FloatToStrF(tp,ffFixed,2,2);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
float n=StrToFloat(Edit1->Text);
float de=StrToFloat(Edit2->Text);
float t=StrToFloat(Edit4->Text);
float uvh=StrToFloat(Edit3->Text);
int i;
int l=0, l1=0;
int c=0, c1=0;
int mas1[10];
int mas[10];
float un=0;
float un1=0;
float add=0;
int x1=0;
int x2,x3,x4,x5,x6;
int x21,x31,x41,x51,x61,x11;
do
{
mas[l]=1;
c++;
for (i=c;i<n;i++)
mas[i]=0;
if (l==0)
{
un=de*pow(2,n-c);
x1=un*10;
}
if (l==1)
{
un=mas[l-1]*de*pow(2,n-c+1)+mas[l]*de*pow(2,n-c);
x2=un*10;
}
if (l==2)
{
un=mas[l-2]*de*pow(2,n-c+2)+mas[l-1]*de*pow(2,n-c+1)+mas[l]*de*pow(2,n-c);
x3=un*10;
}
if (l==3)
{
un=mas[l-3]*de*pow(2,n-c+3)+mas[l-2]*de*pow(2,n-c+2)+mas[l-1]*de*pow(2,n-c+1)+
mas[l]*de*pow(2,n-c);
x4=un*10;
}
if (l==4)
{
un=mas[l-4]*de*pow(2,n-c+4)+mas[l-3]*de*pow(2,n-c+3)+
mas[l-2]*de*pow(2,n-c+2)+mas[l-1]*de*pow(2,n-c+1)+mas[l]*de*pow(2,n-c);
x5=un*10;
}
if (l==5)
{
un=mas[l-5]*de*pow(2,n-c+5)+mas[l-4]*de*pow(2,n-c+4)+mas[l-3]*de*pow(2,n-c+3)+
mas[l-2]*de*pow(2,n-c+2)+mas[l-1]*de*pow(2,n-c+1)+mas[l]*de*pow(2,n-c);
x6=un*10;
}
if (uvh>un)
;
if (uvh==un)
mas[l]=1;
if (uvh<un)
mas[l]=0;
l++;
mas1[l1]=1;
c1++;
for (i=c1;i<n;i++)
mas1[i]=0;
if (l1==0)
{
un1=mas1[l1]*de*pow(2,n-c1);
x11=un1*10;
}
if (l1==1)
{
un1=mas1[l1-1]*de*pow(2,n-c1+1)+mas1[l1]*de*pow(2,n-c1);
x21=un1*10;
}
if (l1==2)
{
un1=mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x31=un1*10;
}
if (l1==3)
{
un1=mas1[l1-3]*de*pow(2,n-c1+3)+mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x41=un1*10;
}
if (l1==4)
{
un1=mas1[l1-4]*de*pow(2,n-c1+4)+mas1[l1-3]*de*pow(2,n-c1+3)+mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x51=un1*10;
}
if (l1==5)
{
un1=mas1[l1-5]*de*pow(2,n-c1+5)+mas1[l1-4]*de*pow(2,n-c1+4)+mas1[l1-3]*de*pow(2,n-c1+3)+mas1[l1-2]*de*pow(2,n-c1+2)+mas1[l1-1]*de*pow(2,n-c1+1)+
mas1[l1]*de*pow(2,n-c1);
x61=un1*10;
}
if (uvh>un1)
mas1[l1]=1;
if (uvh==un1)
mas1[l1]=0;
if (uvh<un1)
mas1[l1]=0;
l1++;
}
while (l!=n);
float map=0;
float mvp=0;
float skap=0;
float skvp=0;
map=de/2;
Edit5->Text=FloatToStrF(map,ffFixed,2,2);
mvp=100/(pow(2,n+1));
Edit6->Text=FloatToStrF(mvp,ffFixed,2,2);
skap=de/(pow(3,0.5)*2);
Edit8->Text=FloatToStrF(skap,ffFixed,2,2);
skvp=100/(pow(3,0.5)*pow(2,n+1));
Edit7->Text=FloatToStrF(skvp,ffFixed,2,2);
Chart1->Visible=true;
Chart2->Visible=true;
if (n==1)
{
Series1->Add(x1,0,clRed);
Series1->Add(x1,1,clRed);
}
if (n==2)
{
Series1->Add(x1,0,clRed);
Series1->Add(x2,1,clRed);
Series1->Add(x2,2,clRed);
}
if (n==3)
{
Series1->Add(x1,0,clRed);
Series1->Add(x2,1,clRed);
Series1->Add(x3,2,clRed);
Series1->Add(x3,3,clRed);
}
if (n==4)
{
Series1->Add(x1,0,clRed);
Series1->Add(x2,1,clRed);
Series1->Add(x3,2,clRed);
Series1->Add(x4,3,clRed);
Series1->Add(x4,4,clRed);
}
if (n==5)
{
Series1->Add(x1,0,clRed);
Series1->Add(x2,1,clRed);
Series1->Add(x3,2,clRed);
Series1->Add(x4,3,clRed);
Series1->Add(x5,4,clRed);
Series1->Add(x5,5,clRed);
}
if (n==6)
{
Series1->Add(x1,0,clRed);
Series1->Add(x2,1,clRed);
Series1->Add(x3,2,clRed);
Series1->Add(x4,3,clRed);
Series1->Add(x5,4,clRed);
Series1->Add(x6,5,clRed);
Series1->Add(x6,6,clRed);
}
if (n==1)
{
Series2->Add(x11,0,clRed);
Series2->Add(x11,1,clRed);
}
if (n==2)
{
Series2->Add(x11,0,clRed);
Series2->Add(x21,1,clRed);
Series2->Add(x21,2,clRed);
}
if (n==3)
{
Series2->Add(x11,0,clRed);
Series2->Add(x21,1,clRed);
Series2->Add(x31,2,clRed);
Series2->Add(x31,3,clRed);
}
if (n==4)
{
Series2->Add(x11,0,clRed);
Series2->Add(x21,1,clRed);
Series2->Add(x31,2,clRed);
Series2->Add(x41,3,clRed);
Series2->Add(x41,4,clRed);
}
if (n==5)
{
Series2->Add(x11,0,clRed);
Series2->Add(x21,1,clRed);
Series2->Add(x31,2,clRed);
Series2->Add(x41,3,clRed);
Series2->Add(x51,4,clRed);
Series2->Add(x51,5,clRed);
}
if(n==6)
{
Series2->Add(x11,0,clRed);
Series2->Add(x21,1,clRed);
Series2->Add(x31,2,clRed);
Series2->Add(x41,3,clRed);
Series2->Add(x51,4,clRed);
Series2->Add(x61,5,clRed);
Series2->Add(x61,6,clRed);
}
}
//---------------------------------------------------------------------------
Додаток 2
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int mas1[10];
int mas[10];
int mask[10];
float n1;
int masa[20];
int masb[20];
int masc[20];
int masd[20];
int mase[20];
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i;
if (CheckBox1->Checked)
{
Label10->Caption=Label10->Caption+"x7+";
mas1[0]=7;
}
if (CheckBox2->Checked)
{
Label10->Caption=Label10->Caption+"x6+";
mas1[1]=6;
}
if (CheckBox3->Checked)
{
Label10->Caption=Label10->Caption+"x5+";
mas1[2]=5;
}
if (CheckBox4->Checked)
{
Label10->Caption=Label10->Caption+"x4+";
mas1[3]=4;
}
if (CheckBox5->Checked)
{
Label10->Caption=Label10->Caption+"x3+";
mas1[4]=3;
}
if (CheckBox6->Checked)
{
Label10->Caption=Label10->Caption+"x2+";
mas1[5]=2;
}
if (CheckBox7->Checked)
{
Label10->Caption=Label10->Caption+"x+";
mas1[6]=1;
}
if (CheckBox8->Checked)
{
Label10->Caption=Label10->Caption+"1";
mas1[7]=0;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int i;
n1=StrToFloat(Edit1->Text);
mas[0]=StrToFloat(Edit2->Text);
mas[1]=StrToFloat(Edit3->Text);
mas[2]=StrToFloat(Edit4->Text);
mas[3]=StrToFloat(Edit5->Text);
mas[4]=StrToFloat(Edit6->Text);
mas[5]=StrToFloat(Edit7->Text);
mas[6]=StrToFloat(Edit8->Text);
mas[7]=StrToFloat(Edit9->Text);
for (i=0;i<=n1-1;i++)
Label11->Caption = Label11->Caption + mas[i] ;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
Edit1->Text="";
Edit2->Text="";
Edit3->Text="";
Edit4->Text="";
Edit5->Text="";
Edit6->Text="";
Edit7->Text="";
Edit8->Text="";
Edit9->Text="";
Label10->Caption="";
Label11->Caption="";
CheckBox1->Checked=False;
CheckBox2->Checked=False;
CheckBox3->Checked=False;
CheckBox4->Checked=False;
CheckBox5->Checked=False;
CheckBox6->Checked=False;
CheckBox7->Checked=False;
CheckBox8->Checked=False;
Label12->Caption="";
Label13->Caption="";
Label14->Caption="";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int h=0;
int r=0;
int j,i,k,l,m;
for (i=n1-1;i>0;i--)
{
if (mas[i]==1)
mas[i]=i;
else
mas[i]=0;
if (mas[0]==1)
mas[0]=1;
}
for (i=n1-1;i>0;i--)
{
if (mas[i]!=0)
{
Label12->Caption = Label12->Caption +"x"+ mas[i]+"+" ;
h++;
}
}
if (mas[0]!=0)
{
Label12->Caption = Label12->Caption + mas[0] ;
h++;
}
int max=0;
for (j=7;j>=0;j--)
{
if (mas1[j]>max)
{
max=mas1[j];
r=max;
}
}
Label13->Caption = Label13->Caption + r ;
for (i=n1-1;i>0;i--)
{
if (mas[i]!=0)
{
mas[i]+=r;
Label14->Caption = Label14->Caption +"x"+ mas[i]+"+" ;
}
}
if (mas[0]!=0)
mas[0]=r;
Label14->Caption = Label14->Caption +"x"+ (mas[0]) ;
i=0;j=0;
for (m=0;m<n1-2+r;m++)
{
for (k=r;k>=0;k--)
{
masa[i]=mas1[i];
masb[j]=mas[j];
masc[k]=masb[j]-masa[i];
for (l=0;l<n1-1+r;l++)
{
masd[l]=masa[i]+masc[k];
i++;
if (masd[l]!=masb[j]) {
mase[m]=masd[l];
masd[l]=mase[m];
}
j++;
}
}
}
for (l=0;l<n1-1+r;l++)
{
Label17->Caption=Label17->Caption + masd[l];
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
if (CheckBox1->Checked)
{
mask[7]=7;
}
if (CheckBox2->Checked)
{
mask[6]=6;
}
if (CheckBox3->Checked)
{
mask[5]=5;
}
if (CheckBox4->Checked)
{
mask[4]=4;
}
if (CheckBox5->Checked)
{
mask[3]=3;
}
if (CheckBox6->Checked)
{
mask[2]=2;
}
if (CheckBox7->Checked)
{
mask[1]=1;
}
if (CheckBox8->Checked)
{
mask[8]=0;
}
int mak[8];
int i;
for (i=1;i<8;i++)
{
if (mask[i]>0)
;
else
mask[i]=99;
}
if(CheckBox8->Checked)
mask[0]=0;
else
mask[0]=99;
for (i=0;i<8;i++)
{
if (mask[i]==99)
mak[i]=0;
else
mak[i]=1;
}
int max=0;
for (i=0;i<8;i++)
if ((mask[i]>max)&&(mask[i]!=99))
max=mask[i];
if((mask[7]!=99)&&(max>7))
{
Image15->Visible=true;
Image14->Visible=true;
}
if((mask[7]==99)&&(max>7))
Image15->Visible=true;
if((mask[6]!=99)&&(max>6))
{
Image2->Visible=true;
Image3->Visible=true;
}
if((mask[6]==99)&&(max>6))
Image2->Visible=true;
if((mask[5]!=99)&&(max>5))
{
Image4->Visible=true;
Image5->Visible=true;
}
if((mask[5]==99)&&(max>5))
Image4->Visible=true;
if((mask[4]!=99)&&(max>4))
{
Image6->Visible=true;
Image7->Visible=true;
}
if((mask[4]==99)&&(max>4))
Image6->Visible=true;
if((mask[3]!=99)&&(max>3))
{
Image8->Visible=true;
Image9->Visible=true;
}
if((mask[3]==99)&&(max>3))
Image8->Visible=true;
if((mask[2]!=99)&&(max>2))
{
Image10->Visible=true;
Image11->Visible=true;
}
if((mask[2]==99)&&(max>2))
Image10->Visible=true;
if((mask[1]!=99)&&(max>1))
{
Image12->Visible=true;
Image13->Visible=true;
}
if((mask[1]==99)&&(max>1))
Image12->Visible=true;
Image1->Visible=true;
}
//---------------------------------------------------------------------------