unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
Edit3: TEdit;
Label3: TLabel;
Edit4: TEdit;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
BitBtn1: TBitBtn;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
Memo1: TMemo;
Edit5: TEdit;
Button6: TButton;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
Type
Abitur=record
FIO:string[40];
ADR:string[40];
oc1,oc2,oc3:string[4];
srb:extended;
end;

var
a:array[1..100]of integer;
Fz:file of Abitur;
Ft:TextFile;
Abit:array[1..100] of Abitur;
nzap:integer;
FNZ,FNT:string;
var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.Clear;Edit2.Clear;Edit3.Clear;Edit4.Clear;Edit5.Clear;Memo1.Clear;
Button1.Hide;
nzap:=0;
end;

procedure TForm1.Button1Click(Sender: TObject);//ввод записи
begin
inc(nzap);
with abit[nzap] do begin
FIO:=Edit1.Text;
ADR:=Edit3.Text;
oc1:=Edit2.Text;
oc2:=Edit4.Text;
oc3:=Edit5.Text;
srb:=(strtofloat(oc1)+strtofloat(oc2)+strtofloat(oc3))/3;
Memo1.Lines.Add(FIO+' '+'г.'+ADR+' '+oc1+' '+oc2+' '+oc3+' '+floattostr(srb));
end;
write(Fz,Abit[nzap]);
Edit1.Clear;Edit2.Clear;Edit3.Clear;Edit4.Clear;Edit5.Clear;
end;


procedure TForm1.Button2Click(Sender: TObject);//создание файла
begin
OpenDialog1.Title:='Создать новый файл';
if OpenDialog1.Execute then begin
FNZ:=OpenDialog1.FileName;
AssignFIle(Fz,FNZ);
Rewrite(Fz);
Button1.Show;
Memo1.Clear;
end;
end;

procedure TForm1.Button3Click(Sender: TObject);//открытие файла
begin
Memo1.Clear;
If OpenDialog1.Execute then begin
FNZ:=OpenDialog1.FileName;
AssignFile(Fz,FNZ);
Reset(FZ);
end;
nzap:=0;
while not(eof(fz)) do begin
inc(nzap);
Read(Fz,abit[nzap]);
with abit[nzap] do
Memo1.Lines.Add(FIO+' '+'г.'+ADR+' '+oc1+' '+oc2+' '+oc3+' '+floattostr(srb));
end;
Button1.Show;
end;

procedure TForm1.Button5Click(Sender: TObject);//сохранение
var i:word;
begin
If SaveDialog1.Execute then begin
FNt:=SaveDialog1.FileName;
AssignFile(Ft,FNt);
Rewrite(Ft);
end;
for i:=1 to nzap do
with abit[i] do writeln(Ft,i,'. ',FIO,' ',ADR,' ',oc1,' ',oc2,' ',oc3,' ',srb);
CloseFile(ft);
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
CloseFile(fz);
end;

procedure TForm1.Button4Click(Sender: TObject);
var i,j:word;
st:abitur;
begin //сортировка по убыванию среднего балла
For i:=1 to nzap do
for j:=1 to nzap do
if abit[i].srb>abit[j].srb then begin
st:=abit[j];
abit[j]:=abit[i];
abit[i]:=st;
end;
Memo1.Clear;
For i:=1 to nzap do
with abit[i] do
Memo1.Lines.Add(IntToStr(i)+' '+FIO+' '+'г.'+ADR+' '+oc1+' '+oc2+' '+oc3+' '+floattostr(srb));
end;

procedure TForm1.Button6Click(Sender: TObject);
var i,k,n:word;
w:abitur;
begin // вывод минчан
reset(fz);n:=0;
while not eof(fz) do
begin
n:=n+1;
read(fz,abit[n]);
end;
closeFile(fz);
for i:=1 to n-1 do
for k:=1 to n-i do
if (abit[k].FIO>abit[k+1].FIO){ and (abit[k].srb>=4.5) and (abit[k].ADR='Минск')}then
begin w:=abit[k]; abit[k]:=abit[k+1]; abit[k+1]:=w; end;
rewrite(fz);
for i:=1 to n do begin write(fz,abit[i]);end;
closeFile(fz);
memo1.Clear;
For n:=1 to nzap do
if (abit[n].srb>=4.5) and (abit[n].ADR='Минск')then
begin
with abit[n] do
Memo1.Lines.Add(IntToStr(n)+' '+FIO+' '+ADR+' '+oc1+' '+oc2+' '+oc3+' '+floattostr(srb));
end;
end;
end.
Соседние файлы в папке Ведомость абитуриентов в Минске
  • #
    15.06.2014188 б67project1.dpr
  • #
    15.06.2014876 б67project1.res
  • #
    15.06.201411.56 Кб67unit1.dcu
  • #
    15.06.201451 б67unit1.ddp
  • #
    15.06.20144.53 Кб68unit1.dfm
  • #
    15.06.20144.18 Кб67unit1.pas
  • #
    15.06.20140 б67абитуриенты.dat
  • #
    15.06.2014720 б67абитуриенты13567.dat
  • #
    15.06.2014840 б67абитуриенты666.dat
  • #
    15.06.2014720 б67копия (2) абитуриенты13567.dat
  • #
    15.06.2014720 б68копия (3) абитуриенты13567.dat