unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Grids, ExtCtrls;
type
TForm1 = class(TForm)
tab1: TStringGrid;
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit4: TEdit;
Bevel1: TBevel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
mac : array[0..10,0..10] of integer;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c,d,i,j,ns,suma1,suma2,suma3 : integer;
begin
a:=0;
b:=0;
c:=0;
d:=0;
for i:=1 to 2 do
begin
for j:=1 to 6 do
begin
mac[i,j]:=StrToInt(tab1.cells[i,j]);
end;
end;
repeat
c:=0;
for j:=1 to 5 do
begin
if mac[1,j]>mac[1,j+1] then
begin
a:=mac[1,j];
b:=mac[2,j];
mac[1,j]:=mac[1,j+1];
mac[2,j]:=mac[2,j+1];
mac[1,j+1]:=a;
mac[2,j+1]:=b;
c:=c+1;
end;
end;
if c=0 then break;
until false;
for j:=1 to 6 do
begin
tab1.cells[1,j]:=inttostr(mac[1,j]);
tab1.cells[2,j]:=inttostr(mac[2,j]);
end;
// --------------- sortowanie end ----------------
ns:=0;
suma1:=0;
suma2:=0;
suma3:=0;
for j:=1 to 6 do
begin
suma1:=suma1+mac[1,j];
mac[3,j]:=suma1;
end;
for j:=1 to 6 do
begin
if mac[3,j]>mac[2,j]
then
begin
mac[5,j]:=mac[3,j]-mac[2,j]; ns:=ns+1; mac[4,j]:=0;
end;
if mac[3,j]<mac[2,j]
then begin mac[4,j]:=mac[2,j]-mac[3,j]; mac[5,j]:=0 end;
end;
for j:=1 to 6 do
begin
suma2:=suma2+mac[3,j];
suma3:=suma3+mac[5,j];
end;
form1.Edit1.Text:=floattostr(mac[3,6]);
form1.Edit2.Text:=floattostr(suma2/6);
if ns<>0 then form1.Edit3.Text:=floattostr(suma3/ns);
form1.Edit4.Text:=floattostr(ns);
for j:=1 to 6 do
begin
tab1.cells[3,j]:=inttostr(mac[3,j]);
tab1.cells[4,j]:=inttostr(mac[4,j]);
tab1.cells[5,j]:=inttostr(mac[5,j]);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i,j: integer;
begin
// form1.tab1.Refresh;
// --------------opis-----------------
tab1.cells[1,0]:='PT';
tab1.cells[2,0]:='DD';
tab1.cells[3,0]:='FT';
tab1.cells[4,0]:='R';
tab1.cells[5,0]:='S';
for i:=1 to 5 do
begin
for j:=1 to 6 do
begin
tab1.cells[i,j]:='0';
end;
end;
end;
end.
0
1
I? Co?
1
moze komus sie przyda a ja sie pochwale ze mialem taki projekt
teorie mam z wykladow