program ST_extraliga;
uses crt;
const maxp=10;
type team=record
muzstvo:string[20];
vyhry:integer;
prehry:integer;
remizy:integer;
body:integer;
end;
pole=array[1..maxp] of team;
var a:pole;
i,p:integer;
znak:char;
pocet:byte;
m,p1:string;
b:integer;
procedure pridaj(var a:pole;i:integer;var p:integer);
begin
clrscr;
i:=p;
if (p<maxp) then
inc(i);inc(p);
writeln('Zadajte nazov teamu, ktory chcete pridat');
writeln;
readln(a.muzstvo);
writeln;
writeln('pocet vyhier');
readln(a.vyhry);
writeln('pocet prehier');
readln(a.prehry);
writeln('pocet remiz');
readln(a.remizy);
end;
procedure zrus (var a:pole;i,p:integer);
var co:integer;
j:integer;
naozaj:char;
begin
clrscr;
writeln;
writeln ('Zoznam teamov :');
writeln;
for i:=1 to p do
writeln(i:1,'. ',a.muzstvo:7);
writeln;
writeln ('Zadaj cislo teamu ktory chces zrusit');
readln (co);
writeln;
writeln;
writeln ('Nazov: ',a[co].muzstvo);
write ('Naozaj chcete zrusit zvoleny team?[a/n] ');
readln (naozaj);
if naozaj='a' then begin
for i:=co to j-1 do begin
a[co]:=a[co+1];
j:=j-1;
end;
end;
end;
procedure zobraz (a:pole;i,p:integer);
var j:integer;
begin
clrscr;
writeln('Zoznam registrovanych teamov:');
writeln;
writeln ('Team':10,'V':3,'P':3,'R':3);
for i:=1 to p do
writeln(i:1,'. ',a.muzstvo:7, a.vyhry:3, a.prehry:3,a.remizy:3);
repeat until keypressed;
end;
procedure tried (a:pole;i,p:integer);
var j,k:pole;
x:integer;
zn:char;
Begin
clrscr;
writeln ('Zoznam teamov :');
writeln;
for i:=1 to p do
writeln(i:1,'. ',a.muzstvo:7,a[i].vyhry:3, a[i].prehry:3,a[i].remizy:3);
writeln;
writeln ('Zadajte kluc podla coho sa maju muzstva zotriedit');
writeln;
writeln ('Pocet vyhier - v');
writeln ('Podla poctu prehier - p');
readln (zn);
{ case zn of
'v': begin
For i:=2 to p do
begin
x:=a[i].vyhry;
j:=i-1;
while x < a[j] do
begin
A[j+1]:=A[j];
j:=j-1; If j = 0 then Break;
end;
A[j+1]:=x;
end;
end;
'p': begin
For i:=2 to p do
begin
x:=a[i].prehry;
j:=i-1;
while x < a[j] do
begin
A[j+1]:=A[j];
j:=j-1; If j = 0 then Break;
end;
A[j+1]:=x;
end;
end;}
end;
begin
clrscr;i:=0;p:=0;
textcolor(2);
while (znak<>'e') do
begin
clrscr;
writeln('Zvolte jednu z nasledujucich moznosti');
writeln('p - pridat muzstvo do registru');
writeln('z - zobrazit listinu teamov');
writeln('o - odstranit muzstvo z registru');
writeln('t - utriedit muzstva');
writeln('e - exit');
writeln;
readln(znak);
case znak of
'p':pridaj(a,i,p);
'z':zobraz(a,i,p);
'o':zrus(a,i,p);
't':tried(a,i,p);
'e':halt(0)
else writeln('Zadali ste chybnu klavesu');
end;
end;
repeat until keypressed;
end.
pascal triedenie HELP !
pascal triedenie HELP !
Ahoj, mam maly problem z jednym programom, potrebujem ho na zajtra do skoly..ale nefunguje mi procedura na triedenie priamym vkladanim..nepozrie sa na to niekto? Stale mi vypisuje chyby..skusal som tam pomenit parametre, ale stale nieco ine vybehlo..
Vdaka vopred
Kód: Vybrať všetko
x:=a[i].vyhry; {x je a[i].vyhry}
j:=i-1;
while x < a[j] do {x je stale a[i].vyhry ale a[j] je cely zaznam a nie a[j].vyhry}hmm..vdaka..) a nevedel by si mi napisat cely kod na to triedenie? staci na tie vyhry, ak by si mal cas..robim to vo free pascale..a ked mam to "a" ako pole - neberie mi znamienka (-,<), alebo ked tam dam inu premenu tak to chce to pole, alebo nieco inejuho napísal:Kód: Vybrať všetko
x:=a[i].vyhry; {x je a[i].vyhry} j:=i-1; while x < a[j] do {x je stale a[i].vyhry ale a[j] je cely zaznam a nie a[j].vyhry}
coze? nejak ta nechapem.
radsej citaj to co pisem
radsej citaj to co pisem
Kód: Vybrať všetko
For i:=2 to p do
begin
x:=a[i].vyhry;
j:=i-1;
while x < a[j].vyhry do {x porovnavas s a[j].vyhry a nie s a[j]}
begin
A[j+1]:=A[j];
j:=j-1; If j = 0 then Break;
end;
A[j+1]:=x;
end; aaa
nj...ja chapem co pises..ale aj tak mi to neberie.."compilation abort";"incompatible types - got "longInt" expected "pole" a kurzor blika na "-" co je j:=i-1 ,..ale aj tak ti vdaka
A tebe to tak ide? ked tak mi skus upnut .pas...budem ti velmi velmi vdacny 