Hello everyone,I'm new to programming,just started making my own database,and I have a task,using InsertionSort using ONLY while/for/if LOOP,to sort my database by last name,so I have this database:
const datoteka='d:\base.txt';
const maxUcenika = 100;
type ucenik=record
ime:string[20];
pre:string[30];
oc:1..5;
end;
var f:file of ucenik;
u:ucenik;
i,j,bruc:integer;
trazenoPrezime:string;
poljeUcenika:array[1..maxUcenika] of ucenik;
procedure upis;
begin
write('Koliko ucenika zelis upisati? --> '); readln(bruc);
for i:=1 to bruc do begin
writeln('ucenik broj ',i);
write('ime: '); readln(u.ime);
write('prezime: '); readln(u.pre);
write('ocjena: '); readln(u.oc);
write(f,u);
end;
end;
procedure ispisIzDatoteke;
begin
seek(f,0);
while not eof(f) do begin
read(f,u);
writeln(u.ime:20, u.pre:30, u.oc:10);
end;
end;
procedure ispisiZapis(n:integer);
begin
if ((n>=0) and (n<filesize(f))) then begin
seek(f,n);
read(f,u);
writeln(u.ime:20, u.pre:30, u.oc:10);
end
else begin
writeln('Broj mora biti izmedju 0 i ',filesize(f)-1);
end;
end;
and I have no idea how to use the insertion sort,I'm googleing it for like 2-3hours,read all the thing on the wiki/and that sort of pages,and now I'm desperate and I need your help :(
Thanks,sincerely
spamserv