gitweb on Svarog
projekti pod git sistemom za održavanje verzija -- projects under the git version control system
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7d6510a)
raw | patch | inline | side by side (parent: 7d6510a)
author | Doni Pracner <quinnuendo@gmail.com> | |
Sat, 15 Feb 2014 17:56:01 +0000 (18:56 +0100) | ||
committer | Doni Pracner <quinnuendo@gmail.com> | |
Sat, 15 Feb 2014 17:56:01 +0000 (18:56 +0100) |
skripta-spa1-sadrzaj.tex | patch | blob | history |
index d9f8e1969b9b8063b499120717aec0c74b85cf41..50655d0b7b895274d8d75526f62d0705823c2fd9 100644 (file)
--- a/skripta-spa1-sadrzaj.tex
+++ b/skripta-spa1-sadrzaj.tex
Potrebno je sve redove iz fajla učitati i ispisati ih na ekran.
-\begin{lstlisting}[style=codeblock]
-MODULE ispis;
-FROM FIO IMPORT File, Open, Close, EOF, RdStr;
-FROM InOut IMPORT WriteString, WriteLn, ReadString;
-
-PROCEDURE ispisF(ime: ARRAY OF CHAR);
-VAR
- f:File;
- s : ARRAY[1..100] OF CHAR;
-BEGIN
- f:=Open(ime);
- EOF := FALSE;
- WHILE NOT EOF DO
- RdStr(f,s);
- WriteString(s);
- WriteLn;
- END;
- Close(f);
-END ispisF;
-
-VAR
- ime: ARRAY[1..100] OF CHAR;
-BEGIN
- WriteString("unesite ime fajla:");
- ReadString(ime);
- ispisF(ime);
-END ispis.
-\end{lstlisting}
+\lstinputlisting[style=codeblock]{kodovi/fajlovi/ispis.mod}
\subsection{Zadatak: spisak studenata}
podatak o jednom studentu, redom prezime, ime i godina rođenja,
razdvojeni razmacima.
-\begin{lstlisting}[style=codeblock]
-MODULE nizslog;
-FROM InOut IMPORT WriteString, WriteLn,
- WriteCard, ReadCard, ReadString;
-FROM FIO IMPORT File, Open, Create, Close, EOF,
- RdItem, RdCard, WrStr, WrCard, WrLn;
-FROM Str IMPORT Compare;
-
-CONST
- MaxStud = 100;
-TYPE
- String = ARRAY[1..30] OF CHAR;
- Student = RECORD
- ime, prez: String;
- god: CARDINAL;
- END;
- Studenti = ARRAY[1..MaxStud] OF Student;
-
-PROCEDURE UcitajF(fajl:String;
- VAR spisak: Studenti; VAR n:CARDINAL);
-VAR
- f:File;
-BEGIN
- n:=0;
- f:= Open(fajl);
- EOF := FALSE;
- WHILE NOT EOF DO
- INC(n);
- RdItem(f, spisak[n].prez);
- RdItem(f, spisak[n].ime);
- spisak[n].god := RdCard(f);
- END;
- Close(f);
-END UcitajF;
-
-PROCEDURE Ispisi(spisak:Studenti; n:CARDINAL);
-VAR
- i: CARDINAL;
-BEGIN
- FOR i:=1 TO n DO
- WriteString(spisak[i].prez);
- WriteString(" ");
- WriteString(spisak[i].ime);
- WriteString(" ");
- WriteCard(spisak[i].god,1);
- WriteLn;
- END;
-END Ispisi;
-
-PROCEDURE IspisiF(fajl:String;
- spisak:Studenti; n:CARDINAL);
-VAR
- f:File;
- i: CARDINAL;
-BEGIN
- IF (n>0) AND (n<=MaxStud) THEN
- f:=Create(fajl);
- (* pravimo takav fajl da ne
- postoji zadnji prazan red *)
- FOR i:=1 TO n-1 DO
- WrStr(f,spisak[i].prez);
- WrStr(f," ");
- WrStr(f,spisak[i].ime);
- WrStr(f," ");
- WrCard(f,spisak[i].god,1);
- WrLn(f);
- END;
- WrStr(f,spisak[n].prez);
- WrStr(f," ");
- WrStr(f,spisak[n].ime);
- WrStr(f," ");
- WrCard(f,spisak[n].god,1);
- Close(f);
- END;
-END IspisiF;
-
-PROCEDURE NoviStudent(VAR spisak:Studenti;
- VAR n:CARDINAL);
-VAR
- stud,temp:Student;
- i:CARDINAL;
- dodaj:BOOLEAN;
-BEGIN
- IF n<MaxStud THEN
- WriteString("Prezime novog studenta?");
- ReadString(stud.prez);
- WriteString("Ime novog studenta?");
- ReadString(stud.ime);
- WriteString("Godina rodjenja");
- WriteString("novog studenta?");
- ReadCard(stud.god);
- (* proverimo da li vec postoji *)
- i:=1;
- dodaj := TRUE;
- WHILE (i<=n) AND dodaj DO
- temp := spisak[i];
- IF (temp.god = stud.god) &
- (Compare(temp.prez,stud.prez)=0) &
- (Compare(temp.ime,stud.ime)=0) THEN
- dodaj:=FALSE;
- END;
- INC(i);
- END;
- IF dodaj THEN
- INC(n);
- spisak[n]:=stud;
- ELSE
- WriteString("podaci vec postoje!");
- END;
- ELSE
- WriteString("popunjen kapacitet!");
- END;
-END NoviStudent;
-
-VAR
- spisak : Studenti;
- fajl:String;
- n:CARDINAL;
-BEGIN
- fajl:="studenti.txt";
- UcitajF(fajl, spisak, n);
- Ispisi(spisak, n);
- NoviStudent(spisak,n);
- IspisiF(fajl, spisak, n);
-END nizslog.
-\end{lstlisting}
+\lstinputlisting[style=codeblock]{kodovi/fajlovi/nizslog.MOD}
\sectionbreak
\section{Liste i pokazivači}