.


:




:

































 

 

 

 


.




 

: 3 2 + +5D. 1.

1

k , n , r d . :

- (t) ,

- CC CD,

- N.

 

.

 

(), 2 3 . : Project1.cpp, Unit1.h, Unit1.cpp, Unit2.h, Unit2.cpp. .

: TForm, TImage, TPanel, TGroupBox, TLabel, TLabeledEdit, TChart, TButton, TUpDown, TStringGrid, ...

 

.

 

r = 0,873 , , .

d = 0,8265 , , , .

.

 

.

 

C++ Builder , .

 

2 ,

 

3

 

:

n = 1

k = 0,32 1/c

d = 0,8265 ( / )2

r = 0,873


 

, , .

, k , n , r d . :

- (t) ,

- CC CD,

- N.

, . (Integrated Development Environment, IDE) ++ Builder.

, . : Project1.cpp, Unit1.h, Unit1.cpp, Unit2.h, Unit2.cpp.

. .


.

 

1. , . . C++Builder 6 2006: Windows: - C++Builder] / . . , . . . : , 2007. 1181 .

2. , . C++ / ; . . . , . ; . . , . . . . .: ; .: . , 2001. 1098 .

3. , . C++: . / , ; [. . . ]. .: , 2004. 608 .

4. , . ++: / . , , ; [. . . . . ]. 4- . .: , 2007. 889 .

5. , . . C++ / . . , . . , . . , . . . : , 2003. 200 .

6. , . . / . . . . 4-, . .: - , 2007. 415 .

7. , . . - / . . , . . , . . ; . . . . -. 3-, . .: - , 2007. 366 .

8. , . . . : / . . , . . , . . . .: (), 2008. 227 .

9. , . . - : / . . , . . , . . , . . . .: (), 2002. 70 .

10. , . . - : / . . , . . . : , 2008. 415 .


 

 

Unit1.cpp

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

#include "Unit2.h"

#include "math.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)

{

//

StringGrid1->Cells[0][0] = "C";

StringGrid1->Cells[1][0] = "t";

float qqq[6]={0,1,2,3,4,5};

float rrr[6]={5,4,3,2,1,0.5};

for(int i=1;i<6+1;i++)

{

StringGrid1->Cells[1][i]=qqq[i-1];

StringGrid1->Cells[0][i]=rrr[i-1];

}

}

//---------------------------------------------------------------------------

 

void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)

{ //. -

StringGrid1->RowCount = UpDown1->Position + 1;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{ //

d = 0.0;

int i, reg_up(0), reg_down(0);

double *y, *x, s1(UpDown1->Position - 1),

s2(0.0), s3(0.0), s4(0.0), s5(0.0), s6(0.0), ca, cb, cc,cd, t;

//

Series1->Clear();

Series2->Clear();

Series3->Clear();

Series4->Clear();

Series5->Clear();

try

{

//

y = new double[UpDown1->Position - 1];

x = new double[UpDown1->Position - 1];

if(!y ||!x) throw " ";

//

ca = StringGrid1->Cells[0][1].ToDouble();

cb = LabeledEdit1->Text.ToDouble();

cc = LabeledEdit2->Text.ToDouble();

cd= LabeledEdit4->Text.ToDouble();

//

if(!ca || cb < 0.0 || cc < 0.0 || cd < 0.0)

throw " 0";

for(i = 0; i < UpDown1->Position - 1; i++)

{

if(StringGrid1->Cells[0][i + 1].ToDouble() > StringGrid1->Cells[0][i + 2].ToDouble())

reg_down++;

else reg_up++;

if(StringGrid1->Cells[0][i + 1].ToDouble() == StringGrid1->Cells[0][i + 2].ToDouble())

throw " ";

if(StringGrid1->Cells[1][i + 1].ToDouble() >= StringGrid1->Cells[1][i + 2].ToDouble())

throw " ";

if(StringGrid1->Cells[1][i+1].ToDouble()< 0||StringGrid1->Cells[0][i + 1].ToDouble()<0)

throw " ";

}

// ,

double t1,t2,t3,t4,t5,t6,b1,b0;

for(i = 0; i < UpDown1->Position - 1; i++)

{

t1= StringGrid1->Cells[0][i + 2].ToDouble();

t2= StringGrid1->Cells[0][i + 1].ToDouble();

t3= StringGrid1->Cells[1][i + 2].ToDouble();

t4=StringGrid1->Cells[1][i + 1].ToDouble();

t5=t1-t2;

t6=t3-t4;

y[i] = log(fabs(t5) /t6);

x[i] = log(StringGrid1->Cells[0][i + 1].ToDouble());

s2 += x[i];

s3 += y[i];

s4 += x[i] * x[i];

s5 += x[i] * y[i];

s6 += y[i] * y[i];

}

// , ,

k = exp((s3 * s4 - s2 * s5) / (s1 * s4 - s2 * s2));

n = (s1 * s5 - s2 * s3) / (s1 * s4 - s2 * s2);

r = (s1 * s5 - s2 * s3) / sqrt((s1 * s4 - s2 * s2) * (s1 * s6 - s3 * s3));

//

for(int i = 1; i <= UpDown1->Position; i++)

{

Series1->AddXY(StringGrid1->Cells[1][i].ToDouble(),StringGrid1->Cells[0][i].ToDouble());

if(ca < 0) throw " ";

if(i == 1)

{

Series2->AddXY(StringGrid1->Cells[1][i].ToDouble(), ca);

Series3->AddXY(StringGrid1->Cells[1][i].ToDouble(), cb);

Series4->AddXY(StringGrid1->Cells[1][i].ToDouble(), cc);

Series5->AddXY(StringGrid1->Cells[1][i].ToDouble(), cd);

}

else

{

t = StringGrid1->Cells[1][i].ToDouble() - StringGrid1->Cells[1][i - 1].ToDouble();

Series3->AddXY(StringGrid1->Cells[1][i].ToDouble(), cb = cb + k *pow(ca, n) * t*2/3);

Series4->AddXY(StringGrid1->Cells[1][i].ToDouble(), cc = cc + k * pow(ca, n)*t/3);

Series5->AddXY(StringGrid1->Cells[1][i].ToDouble(), cd = cd + k * pow(ca, n)*t*5/3);

if(reg_down > reg_up)

Series2->AddXY(StringGrid1->Cells[1][i].ToDouble(), ca =ca-k*pow(ca, n) * t);

else

Series2->AddXY(StringGrid1->Cells[1][i].ToDouble(), ca =ca+k*pow(ca, n) * t);

}

//

d += pow(StringGrid1->Cells[0][i].ToDouble() - ca, 2);

}

//

Application->CreateForm(__classid(TForm2), &Form2);

//

Form2->ShowModal();

delete[]y;

delete[]x;

}

catch(char*str)

{

Series1->Clear();

Series2->Clear();

Series3->Clear();

Series4->Clear();

Series5->Clear();

//

Application->MessageBox(str, "", MB_ICONERROR | MB_OK);

}

catch(EConvertError&)

{

//?

Application->MessageBox(" ", "",

MB_ICONERROR | MB_OK);

delete[]y;

delete[]x;

}

catch(...)

{

//

Application->MessageBox(" ", "",

MB_ICONERROR | MB_OK);

}

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)

{

Form1->Close();

}

//---------------------------------------------------------------------------

Unit1.h

//---------------------------------------------------------------------------

 

#ifndef Unit1H

#define Unit1H

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <Chart.hpp>

#include <ComCtrls.hpp>

#include <ExtCtrls.hpp>

#include <Grids.hpp>

#include <TeEngine.hpp>

#include <TeeProcs.hpp>

#include <Series.hpp>

//---------------------------------------------------------------------------

class TForm1: public TForm

{

__published: // IDE-managed Components

TPanel *Panel1;

TGroupBox *GroupBox1;

TLabeledEdit *LabeledEdit1;

TLabeledEdit *LabeledEdit2;

TChart *Chart1;

TUpDown *UpDown1;

TLabeledEdit *LabeledEdit3;

TStringGrid *StringGrid1;

TButton *Button1;

TButton *Button2;

TPointSeries *Series1;

TLabeledEdit *LabeledEdit4;

TLineSeries *Series5;

TLineSeries *Series4;

TLineSeries *Series3;

TLineSeries *Series2;

TPointSeries *Series6;

void __fastcall FormCreate(TObject *Sender);

void __fastcall UpDown1Click(TObject *Sender, TUDBtnType Button);

void __fastcall Button1Click(TObject *Sender);

void __fastcall Button2Click(TObject *Sender);

private: // User declarations

public: // User declarations

double k, n, d, r;

__fastcall TForm1(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm1 *Form1;

//---------------------------------------------------------------------------

#endif

 

Unit2.cpp

#include <vcl.h>

#pragma hdrstop

#include "Unit2.h"

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm2 *Form2;

//---------------------------------------------------------------------------

__fastcall TForm2::TForm2(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm2::FormShow(TObject *Sender)

{

LabeledEdit2->Text = FloatToStrF(Form1->n, ffGeneral, 4, 4);

LabeledEdit3->Text = FloatToStrF(Form1->k, ffGeneral, 4, 4);

LabeledEdit1->Text = FloatToStrF(Form1->d, ffGeneral, 4, 4);

LabeledEdit4->Text = FloatToStrF(Form1->r, ffGeneral, 4, 4);

}

//---------------------------------------------------------------------------

void __fastcall TForm2::Button1Click(TObject *Sender)

{

Form2->Close();

}

 

Unit2.h

#ifndef Unit2H

#define Unit2H

//---------------------------------------------------------------------------

#include <Classes.hpp>

#include <Controls.hpp>

#include <StdCtrls.hpp>

#include <Forms.hpp>

#include <ExtCtrls.hpp>

//---------------------------------------------------------------------------

class TForm2: public TForm

{

__published: // IDE-managed Components

TGroupBox *GroupBox1;

TLabeledEdit *LabeledEdit1;

TLabeledEdit *LabeledEdit2;

TLabeledEdit *LabeledEdit3;

TLabeledEdit *LabeledEdit4;

TButton *Button1;

void __fastcall FormShow(TObject *Sender);

void __fastcall Button1Click(TObject *Sender);

private: // User declarations

public: // User declarations

__fastcall TForm2(TComponent* Owner);

};

//---------------------------------------------------------------------------

extern PACKAGE TForm2 *Form2;

//---------------------------------------------------------------------------

#endif

 

Project1.cpp

#include <vcl.h>

#pragma hdrstop

//---------------------------------------------------------------------------

USEFORM("Unit1.cpp", Form1);

USEFORM("Unit2.cpp", Form2);

//---------------------------------------------------------------------------

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)

{

try

{

Application->Initialize();

Application->CreateForm(__classid(TForm1), &Form1);

Application->CreateForm(__classid(TForm2), &Form2);

Application->Run();

}

catch (Exception &exception)

{

Application->ShowException(&exception);

}

catch (...)

{

try

{

throw Exception("");

}

catch (Exception &exception)

{

Application->ShowException(&exception);

}

}

return 0;

}

 





:


: 2017-03-11; !; : 318 |


:

:

.
==> ...

1668 - | 1613 -


© 2015-2024 lektsii.org - -

: 0.114 .