1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
   |  
#include<math.h> 
#include <vcl.h> 
#pragma hdrstop 
#include "Unitp2.h" 
//--------------------------------------------------------------------------- 
#pragma package(smart_init) 
#pragma resource "*.dfm" 
TForm2 *Form2; 
int i,j; 
float InputData[3000][3000],meanofinput[3000],Standdeviation[3000]; 
//--------------------------------------------------------------------------- 
__fastcall TForm2::TForm2(TComponent* Owner) 
: TForm(Owner) 
{ 
 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm2::Button1Click(TObject *Sender) 
{ 
TabSheet2->Show(); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm2::Button3Click(TObject *Sender) 
{ 
TabSheet1->Show(); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm2::Button5Click(TObject *Sender) 
{ 
TabSheet3->Show(); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm2::Button6Click(TObject *Sender) 
{ 
TabSheet2->Show(); 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm2::Edit3KeyDown(TObject *Sender, WORD &Key, 
TShiftState Shift) 
{ 
if (Key==VK_RETURN) 
{try 
{int n=(Edit1->Text).ToInt(); 
int p=(Edit3->Text).ToInt(); 
StringGrid1->ColCount=(p); 
StringGrid1->RowCount=(n); 
StringGrid1->Visible=true; 
} 
catch(...) 
{ShowMessage("verifiez si toutes les données sont remplie"); 
} 
} 
} 
//--------------------------------------------------------------------------- 
void __fastcall TForm2::Button8Click(TObject *Sender) 
{ 
for (i = 0; i < StringGrid1->ColCount; i++) 
{ 
for (j = 0; j < StringGrid1->RowCount; j++) 
InputData[j][i]=StrToFloat(StringGrid1->Cells[j][i]); 
} 
for (i=0;i<StringGrid1->RowCount;i++) 
{meanofinput[i]=0; 
for (j=0;j<StringGrid1->ColCount;j++) 
{meanofinput[i]=InputData[j][i]; 
} 
meanofinput[i]=meanofinput[i ]/ StringGrid1->ColCount; 
} 
for ( j=0;j< StringGrid1->RowCount;j++) 
{Standdeviation[j]=0; 
for ( i=0;i<StringGrid1->ColCount;i++) 
{ Standdeviation[j]+=pow(InputData[i][j]-meanofinput[j],2); 
} 
Standdeviation[j]=sqrt(Standdeviation[j]/(( StringGrid1->ColCount)-1 )); 
} 
for (j=0;j<StringGrid1->RowCount;j++) 
{for (i=0;i< StringGrid1->ColCount;i++) 
{InputData[i][j]=(InputData[i][j]-meanofinput[j])/Standdeviation[j]; 
} 
} 
 
for (j=0;j<StringGrid1->RowCount;j++) 
{for (i=0;i< StringGrid1->ColCount;i++) 
StringGrid1->Cells[i][j]=FloatToStr(InputData[i][j]); 
} 
 
} 
//--------------------------------------------------------------------------- | 
Partager