Миқдорий белгиларни вақт оралиғида баҳолаш дастури.
Листинг коди:
double q;
double jok(String p){
char c[10];
string s=p.c_str();
int j=0; j=s.rfind(",");
if(j>0){
s.erase(j, 1); s.insert(j,".");
strncpy(c, s.c_str(),j+3); }
int i=0; i=s.rfind(".");
if(i>0){strncpy(c, s.c_str(),i+3); }
else{ strcpy(c, s.c_str());}
q=atof(c);
return q;
}
float M[50][50]; double My,Y[100],Mxj[100];
int m,n; float s=0;
double Sy,Sxj[100]; double ss=0; double Dy,Dxj[100];
double Ty,Txj[100];
void Btn2Click (TObject *Sender)
{ if(Edit1->Text!="" && Edit2->Text!="" && Edit3->Text!=""){
m=StrToFloat(Edit1->Text);
n=StrToFloat(Edit3->Text);
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
M[j][i]=jok(Atr2->Cells[i][j]);
s+=M[j][i]; } if(i==1){My=(1./m)*s;} else{ Mxj[i]=(1./m)*s;} s=0;
}
for(int i=1;i<=n;i++){
if(i==1){Str2->Cells[1][1]=FloatToStrF(My,ffFixed,4,2);}
else { Str2->Cells[i][1]=FloatToStrF(Mxj[i],ffFixed,4,2);}
}
for(int i=1;i<=m;i++){
ss+=(M[i][1]-My)*(M[i][1]-My);
} Sy=sqrt(1./(m-1)*ss); Str2->Cells[1][2]=FloatToStrF(Sy,ffFixed,4,2);
ss=0;
for(int i=2;i<=n;i++){
for(int j=1;j<=m;j++){ ss+=(M[j][i]-Mxj[i])*(M[j][i]-My);
} Sxj[i]=sqrt(1./(m-1)*ss); ss=0; Str2->Cells[i][2]=FloatToStrF(Sxj[i],ffFixed,4,2); }
ss=0;
for(int i=1;i<=m;i++){
ss+=(M[i][1]-My)*(M[i][1]-My);
} Dy=1./(m-1)*ss; ss=0; Str2->Cells[1][3]=FloatToStrF(Dy,ffFixed,4,2);
ss=0;
for(int i=2;i<=n;i++){
for(int j=1;j<=m;j++){ ss+=(pow(M[j][i]-Mxj[i],2));
} Dxj[i]=1./(m-1)*ss; ss=0; Str2->Cells[i][3]=FloatToStrF(Dxj[i],ffFixed,4,2); }
ss=0;
Ty=sqrt(Dy/m); Str2->Cells[1][4]=FloatToStrF(Ty,ffFixed,4,2);;
for(int i=2;i<=n;i++){
Txj[i]=sqrt(Dxj[i]/m); Str2->Cells[i][4]=FloatToStrF(Txj[i],ffFixed,4,2);}
}
else {ShowMessage();} }
void FormActivate(TObject *Sender)
{
for(int i=1;i<=Str1->ColCount;i++){
if(i==1){ Str1->Cells[i][0]="y"+IntToStr(i);}
else { Str1->Cells[i][0]="x"+IntToStr(i-1);}
Str1->Cells[0][i]=IntToStr(i)+"- kun";
}
Str1->Cells[0][1]="My";
Str1->Cells[0][2]="Sy";
Str1->Cells[0][3]="Dy";
Str1->Cells[0][4]="Ty";
Str1->Cells[0][5]="Iy";
}
float t;
long double Iy,Ixj[50];
void Btn2Click(TObject *Sender)
{ t=StrToFloat(Edit2->Text);
Iy=My+t*Ty;
Str2->Cells[1][5]=FloatToStr(jok(FloatToStr(Iy)));;
for(int i=2;i<=n;i++){
Ixj[i]=Mxj[i]+t*Txj[i]; Str2->Cells[i][5]=FloatToStrF(Ixj[i],ffFixed,4,2);
} }
void Showtalaba1(String l){
String fayz="SELECT * FROM xy WHERE y<="+l;
Form2->ADOQuery1->Close();
Form2->ADOQuery1->SQL->Clear();
Form2->ADOQuery1->SQL->Add(fayz);
Form2->ADOQuery1->Open();
}
void Showtalaba2(String l){
String fayz="SELECT * FROM xy WHERE y<="+l;
Form2->ADOQuery2->Close();
Form2->ADOQuery2->SQL->Clear();
Form2->ADOQuery2->SQL->Add(fayz);
Form2->ADOQuery2->Open();
}
void Showtalaba3(String l){
String fayz="SELECT * FROM xy WHERE y<="+l;
Form2->ADOQuery3->Close();
Form2->ADOQuery3->SQL->Clear();
Form2->ADOQuery3->SQL->Add(fayz);
Form2->ADOQuery3->Open();
}
double Itn[100],Itny, Iti[100], Itiy;
void Btn3Click(TObject *Sender)
{ Form2->Show();
String fayz,x,y,l;
for(int i=1;i<=n;i++){
x=StringGrid2->Cells[i][5];
fayz="UPDATE xy SET x='"+x+"' WHERE y="+i;
Form2->ADOQuery1->Close();
Form2->ADOQuery1->SQL->Clear();
Form2->ADOQuery1->SQL->Add(fayz);
Form2->ADOQuery1->ExecSQL();
l=IntToStr(i);
Showtalaba1(l); }
for(int i=1;i<=n;i++){
x=StringGrid2->Cells[i][6];
fayz="UPDATE xy SET x='"+x+"' WHERE y="+i;
Form2->ADOQuery2->Close();
Form2->ADOQuery2->SQL->Clear();
Form2->ADOQuery2->SQL->Add(fayz);
Form2->ADOQuery2->ExecSQL();
l=IntToStr(i);
Showtalaba2(l); }
for(int i=1;i<=n;i++){
x=StringGrid2->Cells[i][7];
fayz="UPDATE xy SET x='"+x+"' WHERE y="+i;
Form2->ADOQuery3->Close();
Form2->ADOQuery3->SQL->Clear();
Form2->ADOQuery3->SQL->Add(fayz);
Form2->ADOQuery3->ExecSQL();
l=IntToStr(i);
Showtalaba3(l); }
}
void Btn5Click(TObject *Sender)
{
Itny=My+Iy; StringGrid2->Cells[1][6]=FloatToStr(jok(FloatToStr(Itny)));
for(int i=2;i<=n;i++){
Itn[i]=Mxj[i]+Ixj[i]; StringGrid2->Cells[i][6]=FloatToStrF(Itn[i],ffFixed,4,2); }
}
void Btn6Click(TObject *Sender)
{
Itiy=Iy-My; StringGrid2->Cells[1][7]=FloatToStr(jok(FloatToStr(Itiy)));
for(int i=2;i<=n;i++){
Iti[i]=Ixj[i]-Mxj[i]; StringGrid2->Cells[i][7]=FloatToStrF(Iti[i],ffFixed,4,2); }
}
void __fastcall TForm1::Button4Click(TObject *Sender)
{ for(int i=1;iColCount;i++){
for(int j=1;j<=Str1->ColCount;j++){
Str2->Cells[j][i]=" "; StringGrid2->Cells[j][i]=" ";
}}
Do'stlaringiz bilan baham: |