]> mj.ucw.cz Git - ads2.git/blob - lecnotes.tex
Toky: Cviceni
[ads2.git] / lecnotes.tex
1 % Makra pro sazbu zapisku z prednasky
2
3 \input ucwmac.tex
4 \input ucw-verb.tex
5 \input ucw-ofs.tex
6 \input epsf.tex
7
8 \language=\czech
9 \chyph
10 \lefthyphenmin=2
11 \righthyphenmin=2
12 \inlineverbon
13
14 % A5 s 1cm okraji, dolni rozsiren o 10pt, aby se tam veslo cislo stranky
15 \setmargins{1cm}
16 \advance\bottommargin by 10pt
17 \setpaper{a5}
18 \parindent=0.8cm
19
20 % Zacatek prednasky {cislo prednasky}{jmeno prednasky}{jmeno zapisovatele}
21 \def\prednaska#1#2#3{%
22 \line{{\setfonts[/14]\bf #1. #2} \hfil {\it #3}}
23 \vskip 4pt
24 \hrule
25 \medskip
26 }
27
28 % Nadpis {text}
29 \def\h#1{\medbreak\leftline{\bf #1}\nobreak\smallskip\nobreak}
30
31 % Zvyrazneny zacatek odstavce coby podnadpis (napr. vety apod.)
32 \def\s#1{\smallskip\noindent {\bo #1}}
33
34 % A kdyz stoji samostatne (aby se naodlamoval)
35 \def\ss#1{\smallskip\noindent {\bo #1}\par\nobreak}
36
37 % Dùkaz
38 \def\proof{\nobreak\noindent {\sl Dùkaz:} }
39
40 % Srdicko na konci dukazu
41 \def\qed{{\parfillskip=0pt\allowbreak\hfill\nobreak $\heartsuit$\par}}
42
43 % ... pokud je v seznamu:
44 \def\qeditem{{\parfillskip=0pt\hfill\rlap{\hskip\rightskip\llap{$\heartsuit$}}\par}}
45
46 % Zvyrazneni pojmu
47 \def\em#1{{\it #1\/}}
48
49 % Poznamky pod carou
50 \newcount\footcnt
51 \footcnt=0
52 \def\foot#1{\global\advance\footcnt by 1{\parindent=0.25in\parskip=0pt\footnote{$^{\left<\the\footcnt\right>}$}{#1}}}
53
54 % \noindent se casto hodi, tak na nej mame zkratku
55 \let\>=\noindent
56
57 %%% Sazba algoritmu %%%
58
59 %       \algon{jmeno algoritmu}
60 %       \algin popis vstupu
61 %       \:krok
62 %       \:krok
63 %       \::vnoreny krok
64 %       \algout popis vystupu
65 %       \endalgo
66
67 \def\typedalgo#1#2{
68 \vskip\preitemizeskip
69 \begingroup
70 \let\:=\algoitem
71 \parskip=1pt plus 1pt minus 0.3pt
72 \rightskip=2em
73 \itemcount=0
74 {\bo #1\/} \alg{#2}%
75 }
76 \def\algo#1{\typedalgo{Algoritmus}{#1}}
77 \def\proc#1{\typedalgo{Procedura}{#1}}
78 \def\endalgo{\vskip\postitemizeskip\endgroup}
79 \let\endproc=\endalgo
80 \def\algopar{\par
81 \parindent=2em
82 \hangindent=4em
83 \hangafter=1
84 \leavevmode
85 }
86 \def\algoitem{
87 \ifnum\itemcount=0\smallskip\fi
88 \algopar\advance\itemcount by 1
89 \hbox to 2em{\hss \the\itemcount. }%
90 \futurelet\next\algoitemh}
91 \def\algoitemh{\ifx\next:\let\next=\algohang\else\let\next=\relax\fi\next}
92 \def\algohang:{\advance\hangindent by 2em \hskip 2em\futurelet\next\algoitemh}
93 \def\algin{\par{\it Vstup:\/} }
94 \def\algout{\par\smallskip{\it Výstup:\/} }
95
96 % Jmeno algoritmu v textu nebo ve formuli
97 \def\alg#1{\hbox{\csc #1}}
98
99 %%% Konstrukce pouzivane v algoritmech %%%
100
101 % Priraditko
102 \def\={\leftarrow}
103
104 % Komentar
105 \def\cmt#1{~~{\sl (#1)}}
106
107 % Nekolikapismenkova promenna (mozno pouzit v textovem i math modu)
108 \def\<#1>{\leavevmode\hbox{\it #1\/}}
109
110 % Asymptoticke O-cko
111 \def\O{{\cal O}}
112
113 % Vlozeni obrazku {obrazek}{popisek}{sirka}
114 \def\figure#1#2#3{\bigskip\vbox{\centerline{\epsfxsize=#3\epsfbox{#1}}\smallskip\centerline{#2}}\bigskip}
115
116 % Varianta bez popisku
117 \def\fig#1#2{\medskip\centerline{\epsfxsize=#2\epsfbox{#1}}\medskip}
118
119 % Dva obrazky vedle sebe s popiskami
120 \def\twofigures#1#2#3#4#5#6{\bigskip\valign{\vfil##\vfil\cr
121         \halign{\hfil##\hfil\cr
122                 \epsfxsize=#3\epsfbox{#1} \cr
123                 \noalign{\smallskip}
124                 #2\cr}
125         \cr
126         \noalign{\hskip 2em}
127         \halign{\hfil##\hfil\cr
128                 \epsfxsize=#6\epsfbox{#4} \cr
129                 \noalign{\smallskip}
130                 #5\cr}
131         \cr
132 }\bigskip}
133
134 % Obrazek vlozeny do praveho okraje odstavce {obrazek}{sirka}
135 % Pouzit na zacatku odstavce a nejlepe celou konstrukci zavrit do vboxu, aby se nerozlomila
136 \def\inlinefig#1#2{
137 \setbox0=\hbox{\epsfxsize=#2\epsfbox{#1}}
138 \hangindent=-\wd0
139 \advance\hangindent by -3em
140 \dimen0=\ht0
141 \advance\dimen0 by 8ex
142 \advance\dimen0 by \normalbaselineskip
143 \count0=\dimen0
144 \divide\count0 by \normalbaselineskip
145 \hangafter=-\count0
146 \dimen0=\normalbaselineskip
147 \multiply\dimen0 by \count0
148 \vbox to 0pt{}
149 \nointerlineskip
150 \vbox to 0pt{\vbox to \dimen0{\vss\rightline{\box0\hskip 1em}\vss}}
151 \nointerlineskip
152 }
153
154 % Todo
155 \def\todo#1{{\bf TODO: \it #1}}
156
157 % Matematicke symboly
158 \def\symdiff{\mathop{\Delta}}
159
160 % Slozitostni tridy
161 \def\cc#1{\hbox{\setfonts[CMSans/]\bf #1}}
162 \def\P{\cc{P}}
163 \def\NP{\cc{NP}}
164
165 %%% Cislovani verzi %%%
166
167 \def\currentversion{%
168 \the\year
169 -\ifnum\month<10\relax 0\fi\the\month
170 -\ifnum\day<10\relax 0\fi\the\day
171 }
172
173 \footline={\hfil {\tenrm\the\count0}\hfil \llap{\sevenrm\currentversion}}
174
175 %%% Cviceni %%%
176
177 \newcount\excount
178
179 \def\exercises{\medskip
180 \begingroup
181 \h{Cvièení}
182 \nobreak
183 \excount=0
184 \advance\leftskip by 1.5em
185 \parindent=0pt
186 }
187
188 \def\endexercises{\endgroup}
189
190 \long\def\exwith#1#2{\par
191 \advance\excount by 1
192 \>\llap{\hbox to 1.5em{\the\excount\rlap{#1}.\hfil}}%
193 #2}
194
195 % Cviceni obycejne a tezsi
196 \def\ex{\exwith{}}
197 \def\exx{\exwith{*}}
198 \def\exxx{\exwith{*\kern-0.1em*}}
199
200 % Napovedy (pise se pod cviceni, sazi se samostatne pomoci \hints)
201
202 \newwrite\hintaux
203 \immediate\openout\hintaux=hints.aux
204
205 \long\def\hint#1{
206 % \par\>\em{Hint:} #1
207 \immediate\write\hintaux{\noexpand\realhint{\the\excount}{\unexpanded{#1}}
208 }}
209
210 \def\realhint#1#2{\par
211 \>\llap{\hbox to 1.5em{#1.\hfil}}%
212 #2}
213
214 \def\hints{
215 \immediate\closeout\hintaux
216 \h{Nápovìdy ke cvièením}
217 \nobreak
218 {
219 \advance\leftskip by 1.5em
220 \parindent=0pt
221 \input hints.aux
222 \par
223 }
224 }
225
226 % Reseni cviceni, pise pod cviceni (a pripadne pod \hint)
227 %\long\def\solution#1{\par
228 %\>\em{Øe¹ení:} #1}
229
230 %%% Odkazy na kapitoly a jine objekty %%%
231
232 % Poridime si soubor, do ktereho budeme zapisovat identifikatory
233 \newwrite\ids
234 \def\writeid#1#2{\immediate\write\ids{\string\def\expandafter\string\csname id#1\endcsname{#2}}}
235
236 \immediate\openin\ids=ids.aux
237 \ifeof\ids
238 \else
239 \input ids.aux
240 \fi
241 \immediate\closein\ids
242 \immediate\openout\ids=ids.aux
243
244 \def\ref#1{\expandafter\ifx\csname id#1\endcsname\relax
245 {\bo ??}%
246 \immediate\write16{*** Warning: Reference #1 undefined ***}%
247 \else
248 \csname id#1\endcsname
249 \fi
250 }