Mám program, který má vylosovat zadanej počet žáků ke zkoušení. Mám ho udělanej s pomocí jednoho celkem znalce v oboru, ale už na mě nemá čas :-) .
Problém je v tom, že při spouštění mi to stále hlásí syntaktickou chybu a já jako nepříliš velkej znalec ji nemůžu najít. Dík za pomoc
Uses crt;
type student = record
prij,jmeno :string;
vybran :boolean;
end;
var pole : array [1..30] of student;
T:text;
z,zkous:integer;
procedure los(zaci:integer);
var student,b:integer;
begin
randomize;
for b:= 1 to z do
begin
repeat
student :=random(z)+1;
until pole[student].vybran =false;
pole[student].vybran := true;
writeln(pole[student].prijm,' ',pole[student].jmeno);
end;
end;
begin
z:=0;
assign(T,'C:\simpas\zaci.txt');
reset(T);
while not eof(T) do
begin
z:=z +1;
read(T, zaci[z].prijm);
readln(T, zaci[z].jmeno);
pole[z].vybran := false;
end;
close(T);
writeln('Pocet studentu ke zkouseni?: ');
readln(zkous);
writeln ('Vybrani byli tito studenti:');
writeln;
los(zkous);
readln;
end.
Kurzor se zastavuje na 6.řádku.
Pascal - syntaktická chyba
-
- Level 1
- Příspěvky: 59
- Registrován: červen 09
- Pohlaví:
- Stav:
Offline
Re: Pascal - syntaktická chyba
Už jsem paskal pár let neviděl, ale typoval bych že chyba je v deklaraci array, viz : http://pascal.webz.cz/kurs/lekce/lekce8.htm
Re: Pascal - syntaktická chyba
Takhle mi to funguje v D7 ,ale nemáš tam nikde pole " zaci[]"
Kód: Vybrat vše
program Project1;
Uses crt;
type student = record
prij,jmeno :string;
vybran :boolean;
end;
var pole : array [1..30] of student;
T:text;
z,zkous:integer;
procedure los(zaci:integer);
var student,b:integer;
begin
randomize;
for b:= 1 to z do
begin
repeat
student :=random(z)+1;
until pole[student].vybran =false;
pole[student].vybran := true;
writeln(pole[student].prij,' ',pole[student].jmeno);
end;
end;
begin
z:=0;
assign(T,'C:\simpas\zaci.txt');
reset(T);
while not eof(T) do
begin
z:=z +1;
//read(T, zaci[z].prijm);
//readln(T, zaci[z].jmeno);
pole[z].vybran := false;
end;
close(T);
writeln('Pocet studentu ke zkouseni?: ');
readln(zkous);
writeln ('Vybrani byli tito studenti:');
writeln;
los(zkous);
readln;
end.
Re: Pascal - syntaktická chyba
Takhle to mám nyní. Ale na řádku 30, read(T,student[z].prijm); to po mě chce závorku. Nevím co s tím. Předem dík za radu.
Kód: Vybrat vše
program losovani;
Uses crt;
type student =record
prijm,jmeno :string;
vybran :boolean;
end;
var pole : array [0..30] of student;
T:text;
z,zkous:integer;
procedure los(zaci:integer);
var student,b:integer;
begin
randomize;
for b:= 1 to z do
begin
repeat
student :=random(z)+1;
until pole[student].vybran =false;
pole[student].vybran :=true;
writeln (pole[student].prijm,'',pole[student].jmeno);
end;
end;
begin
z:=0;
assign(T,'C:\simpas\simpas\zaci.txt');
reset(T);
while not eof(T) do
begin
z:=z +1;
read(T,student[z].prijm);
readln(T, student[z].jmeno);
pole[z].vybran := false;
end;
close(T);
writeln('Pocet studentu ke zkouseni?: ');
readln(zkous);
writeln ('Vybrani byli tito studenti:');
writeln;
los(zkous);
readln;
end.
-
- Level 1
- Příspěvky: 59
- Registrován: červen 09
- Pohlaví:
- Stav:
Offline
Re: Pascal - syntaktická chyba
a nemá tam být místo read, readln ??
Re: Pascal - syntaktická chyba
>readln(T, student[z].jmeno);< - student není pole ,ale datový typ.
Vypadat by to mnělo třeba takto:
var s:string;
st:student;
Read(T,s);
st.jmeno:=s;
Vypadat by to mnělo třeba takto:
var s:string;
st:student;
Read(T,s);
st.jmeno:=s;
-
- Mohlo by vás zajímat
- Odpovědi
- Zobrazení
- Poslední příspěvek
-
- 16
- 7583
-
od petr22
Zobrazit poslední příspěvek
02 dub 2025 21:50
-
- 4
- 3238
-
od Steage7717
Zobrazit poslední příspěvek
12 lis 2024 18:49
-
- 4
- 1097
-
od zik9
Zobrazit poslední příspěvek
12 čer 2025 15:33
-
- 6
- 10143
-
od atari
Zobrazit poslední příspěvek
16 bře 2025 11:11
-
- 22
- 9605
-
od Speed_dead
Zobrazit poslední příspěvek
16 srp 2024 10:20
Zpět na “Programování a tvorba webu”
Kdo je online
Uživatelé prohlížející si toto fórum: Žádní registrovaní uživatelé a 4 hosti