Po uspesnom skompilovani a spusteni to pise chybu:
Lazarus: Project project1.exe raised exception class 'External: SIGSEGV'.
Free Pascal: Runtime error 3 at $00402346
$00409181
Vie niekto co to znamena?
Kód:
program project1;
uses crt,graph;
const r=10; {pocet otazok pre kazdu uroven}
var f,e:text;
n,o:string[2];
k,l,i,g,t,h:integer;
gd,gm:smallint;
otazka,kvyhra,vyhra,pvyhra,pom,a,b,c,d,so: string;
odpoved,m:char;
procedure obraz;{vytvori obraz}
begin
setbkcolor(black);
setlinestyle (0,0,1);
setcolor(2);
line (24,379,299,379);
line (299,379,299,404);
line (24,404,299,404);
line (24,379,24,404);
floodfill (28,400,2);
setcolor(2);
line (339,379,614,379);
line (614,379,614,404);
line (614,404,339,404);
line (339,404,339,379);
floodfill (340,380,2);
setcolor(2);
line (24,419,299,419);
line (299,419,299,444);
line (299,444,24,444);
line (24,444,24,419);
floodfill (28,430,2);
setcolor(2);
line (339,419,614,419);
line (614,419,614,444);
line (614,444,339,444);
line (339,444,339,419);
floodfill (420,420,2);
setcolor(2);
line (24,339,614,339);
line (614,339,614,364);
line (614,364,24,364);
line (24,364,24,339);
floodfill (30,340,2);
settextstyle (0,0,1);
setcolor (6);
outtextxy (35,391,'A:');
outtextxy (350,391,'B:');
outtextxy (35,431,'C:');
outtextxy (350,431,'D:');
end;
procedure press;
var a,b:integer;
begin
repeat
settextstyle (0,0,1);
setcolor(white);
outtextxy(250,400,'Press any key');
delay(500);
settextstyle (0,0,1);
setcolor(black);
outtextxy(250,400,'Press any key');
delay(500);
until keypressed;
end;
procedure vypln;{zmaze obrazovku}
var a:integer;
begin
a:=0;
setlinestyle(0,0,3);
repeat
setcolor(0);
line(0,a,640,a);
a:=a+1;
delay(1);
until a>480;
setlinestyle(0,0,1);
end;
procedure vyhravypis;{vypis vyhru}
begin
setcolor (2);
settextstyle (1,0,6);
outtextxy (240,150,'VYHRA');
setcolor (4);
setlinestyle (0,0,1);
line (120,320,520,320);
line (120,360,520,360);
line (100,340,120,320);
line (100,340,120,360);
line (540,340,520,320);
line (540,340,520,360);
end;
procedure k_vyhran;{urci vyhru}
begin
setcolor (2);
settextstyle (1,0,6);
outtextxy (160,120,'Gratulujem');
outtextxy (170,190,'vyhrali ste:');
setcolor (4);
setlinestyle (0,0,1);
line (120,320,520,320);
line (120,360,520,360);
line (100,340,120,320);
line (100,340,120,360);
line (540,340,520,320);
line (540,340,520,360);
settextstyle (0,0,1);
setcolor(4);
outtextxy (40,460,'Vasa odpoved bola nespravna.');
end;
procedure k_vyhras;{urci vyhru}
begin
setcolor (2);
settextstyle (1,0,6);
outtextxy (160,120,'Gratulujem');
outtextxy (170,190,'vyhrali ste:');
setcolor (4);
setlinestyle (0,0,1);
line (120,320,520,320);
line (120,360,520,360);
line (100,340,120,320);
line (100,340,120,360);
line (540,340,520,320);
line (540,340,520,360);
settextstyle (0,0,1);
setcolor(4);
outtextxy (40,460,'Zodpovedali ste');
outtextxy (175,460,o);
outtextxy (190,460,'otazok.');
end;
procedure sodpoved(odp,sodp,vyh,kvyh,pvyh:string);{spravnost odpovede}
begin
if (odp<>sodp) and (odp<>'e') then begin
vypln;
k_vyhran;
setcolor (6);
settextstyle (1,0,4);
outtextxy(240,320,kvyh);
press;
vypln;
end;
if odp=sodp then begin
vypln;
vyhravypis;
setcolor (6);
settextstyle (1,0,4);
outtextxy (240,320,vyh);
delay(1500);
vypln;
end;
if odp='e' then begin
vypln;
k_vyhras;
setcolor (6);
settextstyle (1,0,4);
outtextxy(240,320,pvyh);
press;
vypln;
end;
end;
function premena(q:string):string;
var w:integer;
e:char;
begin
w:=length(q);
if (w=2) then begin
q[2]:=succ(q[2]);
end;
if (w=1) and (q[1]<>'9') then begin
q[1]:=succ(q[1]);
end;
if (w=1) and (q[1]='9') then begin q:='';q:='10';end;
premena:=q;
end;
{zaciatok programu}
begin
gd:=detect;
InitGraph(gd,gm, 'E:\egavga.bgi');
vypln;
setbkcolor (15);
settextstyle (1,0,5);
setcolor (1);
outtextxy (220,210,'Milionar');
settextstyle (0,0,1);
setcolor (4);
outtextxy (40,460,'info[i]');
press;
b:=readkey;{info}
if b=chr(105) then begin
vypln;
setbkcolor (15);
settextstyle (1,0,3);
setcolor (1);
outtextxy (40,80,'a - oznacenie odpovede A');
outtextxy (40,110,'b - oznacenie odpovede B');
outtextxy (40,140,'c - oznacenie odpovede C');
outtextxy (40,170,'d - oznacenie odpovede D');
outtextxy (40,200,'e - ukoncit hru');
settextstyle (0,0,1);
setcolor(4);
outtextxy (40,460,'exit[e]');
delay(250);
b:=readkey;
if b=chr(101) then begin
delay (500);
end;
end;
vypln;
delay (500);
repeat
k:=0;
o:='0';
repeat
assign (f,'Subory\otazky.txt');
reset(f);
randomize;
l:=random(10)+1;
g:=(60*k)+(6*l)+1;
n:=o;
n:=premena(n);
setcolor(2);
settextstyle(1,0,6);
outtextxy (170,140,'Otazka c.');outtextxy(415,140,n);
for i:=1 to 900 do begin
readln(f,pom);
if i=g then otazka:=pom;
if i=g+1 then a:=pom;
if i=g+2 then b:=pom;
if i=g+3 then c:=pom;
if i=g+4 then d:=pom;
if i=g+5 then so:=pom;
end;
close(f);
assign (e,'subory\vyhry.txt');
reset(e);
t:=k*3;
for i:=1 to 45 do begin
readln(e,pom);
if i=t+1 then pvyhra:=pom;
if i=t+2 then vyhra:=pom;
if i=t+3 then kvyhra:=pom;
end;
close(e);
obraz;
outtextxy (45,350,otazka);
outtextxy (55,391,a);
outtextxy (370,391,b);
outtextxy (55,431,c);
outtextxy (370,431,d);
delay(500);
repeat
odpoved:=readkey;
until (odpoved='a') or (odpoved='b') or (odpoved='c') or (odpoved='d') or (odpoved='e');
delay(500);
sodpoved(odpoved,so,vyhra,kvyhra,pvyhra);
delay(1000);
k:=k+1;
o:=premena(o);
until (k>15) or (odpoved='e') or (odpoved<>so);
keypressed;
setbkcolor(0);
vypln;
settextstyle(1,0,4);
setcolor(14);
outtextxy(100,200,'Chcete ukoncit hru ? (A/N)');
repeat
m:=readkey;
until (m='a') or (m='n');
if m='n' then begin
outtextxy(115,250,'Nie nechcem ukoncit hru');
delay(900);
vypln;
end;
until m='a';
if m='a' then begin
outtextxy(125,250,'Ano chcem ukoncit hru');
delay (600);
vypln;
setbkcolor (0);
setcolor (14);
settextstyle (1,0,6);
outtextxy (85,165,'Vypinam Milionara');
setcolor(4);
settextstyle (0,0,2);
outtextxy (20,450,'please wait...');
delay (3000);
end;
closegraph;
end.