CALCULS4.PAS 2.44 KB
Newer Older
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
90
91
92
93
94
95
96
Unit CALCULS4;

interface
 uses Utilit,Declara;


procedure TriChronique(var ZFic:YtypFod; ZNbNul : longint; ZTouComNul : double;
                       var ZQmoy,ZQmed,ZQmax,ZQmin : double; var ZQRare,ZQfrequent : YtypFreq);

IMPLEMENTATION
{=======================================================================}
procedure TriChronique(var ZFic:YtypFod; ZNbNul : longint; ZTouComNul : double;
                       var ZQmoy,ZQmed,ZQmax,ZQmin : double; var ZQRare,ZQfrequent : YtypFreq);
 const
  XNomFicTri   : string = 'TRI';
  XNul         : double = 0;
 var
  XFic         : YTypFod;
  XRang        : longint;
  Xeffectif    : longint;
  XQ           : double;
  XQpred       : double;
  XStop        : boolean;
  Xi           : integer;
  Xfreq : double;
 begin
  assign(XFic,YRepT+XNomFicTri);
  rewrite(XFic);
  reset(ZFic);
  ZQmoy:=0;
  repeat
   read(ZFic,XQ);
   ZQmoy:=ZQmoy+XQ;
   if XQ>ZTouComNul then
    begin
     XStop:=false;
     XRang:=filesize(XFic)-1;
     seek(Xfic,amaxin(0,Xrang));
     while (XRang>=0) and (not Xstop) do
      begin
       read(XFic,XQpred);
       if XQPred>XQ then
        XStop:=true
       else
        begin
         write(XFic,XQPred);
         XRang:=XRang-1;
         seek(XFic,amaxin(0,XRang));
        end;
      end;
     write(XFic,XQ);
    end;
  until eof(ZFic);
  seek(Xfic,filesize(XFic));
  for XRang:=1 to ZNbNul do
   write(XFic,XNul);
  reset(XFic);
  reset(Zfic);
  repeat
   read(XFic,XQ);
   write(ZFic,XQ);
  until eof(XFic);
  close(XFic);
  reset(ZFic);
  read(ZFic,ZQmax);
  XEffectif:=filesize(ZFic);
  seek(ZFic,XEffectif-1);
  read(Zfic,ZQmin);
  ZQmoy:=ZQmoy/XEffectif;
  for Xi:=1 to YNbFreq do
   begin
    XFreq:=1/YTpsFreq[Xi];
    XRang:=amaxlongint(1,trunc((XEffectif+YB)*Xfreq+YA));
    seek(ZFic,XRang-1);
    read(ZFic,XQpred,XQ);
    ZQRare[Xi]:=XQPred+(XQ-XQpred)*(XFreq-(XRang-YA)/(XEffectif+YB))*(XEffectif+YB);
   end;
  XFreq:=0.5;
  XRang:=amaxlongint(1,trunc((XEffectif+YB)*XFreq+YA));
  seek(ZFic,XRang-1);
  read(ZFic,XQpred,XQ);
  ZQmed:=XQPred+(XQ-XQpred)*(XFreq-(XRang-YA)/(XEffectif+YB))*(XEffectif+YB);
  for Xi:=1 to YNbFreq do
   begin
    XFreq:=1-1/YTpsFreq[YNbFreq+1-Xi];
    XRang:=aminlongint(XEffectif-1,trunc((XEffectif+YB)*Xfreq+YA));
    seek(ZFic,XRang-1);
    read(ZFic,XQpred,XQ);
    ZQFrequent[Xi]:=XQPred+(XQ-XQpred)*(XFreq-(XRang-YA)/(XEffectif+YB))*(XEffectif+YB);
   end;
  close(ZFic);
 end;

{=======================================================================}
BEGIN
END.