Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Zadanie 3
- \IncMargin{1em}
- \begin{algorithm}
- \SetKwData{Smarowanie}{\textbf{Smaruj}}
- \SetKwData{Load}{\textbf{load}}
- \SetKwData{This}{\textbf{this}}
- \SetKwData{Then}{\textbf{Then}}
- \SetKwData{Return}{\textbf{Return}}
- \SetKwData{Var}{\textbf{var}}
- \SetKwFunction{Union}{Union}
- \SetKwFunction{FindCompress}{FindCompress}
- \SetKwInOut{Input}{input}
- \SetKwInOut{Output}{output}
- \Input{Chleb, masło, szynka, ser}
- \Output{Kanapka}
- \BlankLine
- \Var kanapka\;
- \Load chleb\;
- \Load masło\;
- \Load ser\;
- \Load szynka\;
- kanapka = chleb\;
- \While{(!(kanapka posmarowana masłem))}{
- kanapka += \Smarowanie masło\;
- \textcolor{orange}{\tcp*[h]{Nie zniszcz chleba!}}
- }
- \Then $kanapka\leftarrow ser$\;
- \Then $kanapka\leftarrow szynka$\;
- \Return kanapka\;
- \end{algorithm}
- \DecMargin{1em}
- Zadanie 4
- \IncMargin{1em}
- \begin{algorithm}
- \SetKwData{Left}{\textbf{left}}
- \SetKwData{This}{\textbf{this}}
- \SetKwData{Up}{\textbf{up}}
- \SetKwFunction{Union}{Union}
- \SetKwFunction{FindCompress}{FindCompress}
- \SetKwInOut{Input}{input}
- \SetKwInOut{Output}{output}
- \Input{A bitmap $Im$ of size $w\times l$}
- \Output{A partition of the bitmap}
- \BlankLine
- \For{$i\leftarrow 2$ \KwTo $l$}{
- {$j\leftarrow 2$ \KwTo $w$}{\label{forins}
- \Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}\\
- \Up$\leftarrow$ \FindCompress{$Im[i-1,]$}\\
- \This$\leftarrow$ \FindCompress{$Im[i,j]$}\\
- \If{\Left \textcolor{red}{compatible with} \This}{
- \lIf{\Left $<$ \This}{\Union{\Left,\This}}
- \lElse{\Union{\This,\Left}}
- }
- \If{\Up \textcolor{red}{compatible with} \This}{
- \lIf{\Up $<$ \This}{\Union{\Up,\This}}
- \textcolor{orange}{\tcp{\This is put under \Up to keep tree as flat as possible}\label{cmt}}
- \lElse{\Union{\This,\Up}}
- \textcolor{orange}{\tcp*[h]{\This linked to \Up}\label{lelse}}
- }
- }
- \lForEach{element $e$ of the line $i$}{\FindCompress{p}}
- }
- \end{algorithm}
- \DecMargin{1em}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement