Код
program subd;
uses crt;
const nn=70;
type zap=record
fam: array [1..nn] of string;
dp,mp,yp: array [1..nn] of integer;
inn: array [1..nn] of char;
kurs: array [1..nn] of char;
group: array [1..nn] of string;
dr,mr,yr: array [1..nn] of real;
predmet: array [1..nn] of string;
ocenka: array [1..nn] of integer;
end;
var
f: text;
f1:text;
z: zap;
t,s1,s2:string;
flag:boolean;
b,o:array [1..nn] of integer;
n,m,i,k:integer;
l:string;
ii,j,t,kk:integer;
flagsort: boolean;
begin
assign( f,'data.txt');
assign(f1,'buf.txt');
rewrite(f1);
close(f1);
rewrite(f);
close(f);
CLRSCR;
writeln('enter kolichestvo studentov '); read(n);
writeln('enter kolichestvo predmetov '); readln(k);
for m:=1 to n do
begin
clrscr;
write('enter family '); readln(z.fam[m]);
write('enter inn '); readln(z.inn[m]);
write('enter kurs '); readln(z.kurs[m]);
write('enter group '); readln(z.group[m]);
write('enter data rojdeniya dd mm yyyy '); readln(z.dr[m],z.mr[m],z.yr[m]);
rewrite(f1);
close(f1);
write('enter data postupleniya dd mm yyyy '); readln(z.dp[m],z.mp[m],z.yp[m]);
for i:=1 to k do begin
write('enter names predmet '); readln(z.predmet[i]);
write('enter ocenka '); readln(z.ocenka[i]);
append(f1);
write(f1,z.ocenka[i],' ');
close(f1);
{srednii ball-----------------------------------------------------------------------}
reset(f1);
j:=1;
while not eof(f1) and (j<=nn) do
begin
read(f1,b[j]);
inc(i);
o[m]:=o[m]+b[j];
end;
end;
append(f1);
writeln(f1);
close(f1);
end;
{_______________________________________________________________________________
____}
begin
repeat
flagsort:=true;
for m:=1 to n-1 do
if not(o[m]<=x[m+1]) then begin
t:=x[m];
x[m]:=x[m+1];
x[m+1]:=j;
kk:=i;
while (kk>1)and not(o[kk-1]<=o[kk]) do begin
t:=o[kk];
o[kk]:=o[j-1];
o[kk-1]:=t;
dec(kk);
end;
flagsort:=false;
end;
until flagsort;
end;
clrscr;
readln;
{alfavit----------------------------------------------------------------------------}
For i := 1 To n Do
For m := n DownTo i+1 Do
If z.fam[Pred(m)] > z.fam[m] Then Begin
T := z.fam[Pred(m)]; z.fam[Pred(m)] := z.fam[m]; z.fam[m] := T
End;
writeln('famili v alfavitnom poryadke:');
for m:=1 to n do begin
append(f);
writeln(f,z.fam[m]);
writeln(z.fam[m]);
end;
{-----------------------------------------------------------------------------------}
read(l);
write(l);
end.
uses crt;
const nn=70;
type zap=record
fam: array [1..nn] of string;
dp,mp,yp: array [1..nn] of integer;
inn: array [1..nn] of char;
kurs: array [1..nn] of char;
group: array [1..nn] of string;
dr,mr,yr: array [1..nn] of real;
predmet: array [1..nn] of string;
ocenka: array [1..nn] of integer;
end;
var
f: text;
f1:text;
z: zap;
t,s1,s2:string;
flag:boolean;
b,o:array [1..nn] of integer;
n,m,i,k:integer;
l:string;
ii,j,t,kk:integer;
flagsort: boolean;
begin
assign( f,'data.txt');
assign(f1,'buf.txt');
rewrite(f1);
close(f1);
rewrite(f);
close(f);
CLRSCR;
writeln('enter kolichestvo studentov '); read(n);
writeln('enter kolichestvo predmetov '); readln(k);
for m:=1 to n do
begin
clrscr;
write('enter family '); readln(z.fam[m]);
write('enter inn '); readln(z.inn[m]);
write('enter kurs '); readln(z.kurs[m]);
write('enter group '); readln(z.group[m]);
write('enter data rojdeniya dd mm yyyy '); readln(z.dr[m],z.mr[m],z.yr[m]);
rewrite(f1);
close(f1);
write('enter data postupleniya dd mm yyyy '); readln(z.dp[m],z.mp[m],z.yp[m]);
for i:=1 to k do begin
write('enter names predmet '); readln(z.predmet[i]);
write('enter ocenka '); readln(z.ocenka[i]);
append(f1);
write(f1,z.ocenka[i],' ');
close(f1);
{srednii ball-----------------------------------------------------------------------}
reset(f1);
j:=1;
while not eof(f1) and (j<=nn) do
begin
read(f1,b[j]);
inc(i);
o[m]:=o[m]+b[j];
end;
end;
append(f1);
writeln(f1);
close(f1);
end;
{_______________________________________________________________________________
____}
begin
repeat
flagsort:=true;
for m:=1 to n-1 do
if not(o[m]<=x[m+1]) then begin
t:=x[m];
x[m]:=x[m+1];
x[m+1]:=j;
kk:=i;
while (kk>1)and not(o[kk-1]<=o[kk]) do begin
t:=o[kk];
o[kk]:=o[j-1];
o[kk-1]:=t;
dec(kk);
end;
flagsort:=false;
end;
until flagsort;
end;
clrscr;
readln;
{alfavit----------------------------------------------------------------------------}
For i := 1 To n Do
For m := n DownTo i+1 Do
If z.fam[Pred(m)] > z.fam[m] Then Begin
T := z.fam[Pred(m)]; z.fam[Pred(m)] := z.fam[m]; z.fam[m] := T
End;
writeln('famili v alfavitnom poryadke:');
for m:=1 to n do begin
append(f);
writeln(f,z.fam[m]);
writeln(z.fam[m]);
end;
{-----------------------------------------------------------------------------------}
read(l);
write(l);
end.
М | Пожалуйста, уважайте тех, кто будет читать Вашу программу - пользуйтесь тегами [cоde=pas] ... [/cоde] мисс_граффити |
Добавлено через 7 мин.
нужно упорядочить средний балл студентов по возрастанию