Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. Zadanie 3
  2.  
  3. \IncMargin{1em}
  4. \begin{algorithm}
  5. \SetKwData{Smarowanie}{\textbf{Smaruj}}
  6. \SetKwData{Load}{\textbf{load}}
  7. \SetKwData{This}{\textbf{this}}
  8. \SetKwData{Then}{\textbf{Then}}
  9. \SetKwData{Return}{\textbf{Return}}
  10. \SetKwData{Var}{\textbf{var}}
  11. \SetKwFunction{Union}{Union}
  12. \SetKwFunction{FindCompress}{FindCompress}
  13. \SetKwInOut{Input}{input}
  14. \SetKwInOut{Output}{output}
  15. \Input{Chleb, masło, szynka, ser}
  16. \Output{Kanapka}
  17. \BlankLine
  18. \Var kanapka\;
  19. \Load chleb\;
  20. \Load masło\;
  21. \Load ser\;
  22. \Load szynka\;
  23. kanapka = chleb\;
  24. \While{(!(kanapka posmarowana masłem))}{
  25. kanapka += \Smarowanie masło\;
  26. \textcolor{orange}{\tcp*[h]{Nie zniszcz chleba!}}
  27. }
  28. \Then $kanapka\leftarrow ser$\;
  29. \Then $kanapka\leftarrow szynka$\;
  30. \Return kanapka\;
  31. \end{algorithm}
  32. \DecMargin{1em}
  33.  
  34.  
  35. Zadanie 4
  36.  
  37.  
  38. \IncMargin{1em}
  39. \begin{algorithm}
  40. \SetKwData{Left}{\textbf{left}}
  41. \SetKwData{This}{\textbf{this}}
  42. \SetKwData{Up}{\textbf{up}}
  43. \SetKwFunction{Union}{Union}
  44. \SetKwFunction{FindCompress}{FindCompress}
  45. \SetKwInOut{Input}{input}
  46. \SetKwInOut{Output}{output}
  47. \Input{A bitmap $Im$ of size $w\times l$}
  48. \Output{A partition of the bitmap}
  49. \BlankLine
  50. \For{$i\leftarrow 2$ \KwTo $l$}{
  51. {$j\leftarrow 2$ \KwTo $w$}{\label{forins}
  52. \Left$\leftarrow$ \FindCompress{$Im[i,j-1]$}\\
  53. \Up$\leftarrow$ \FindCompress{$Im[i-1,]$}\\
  54. \This$\leftarrow$ \FindCompress{$Im[i,j]$}\\
  55. \If{\Left \textcolor{red}{compatible with} \This}{
  56. \lIf{\Left $<$ \This}{\Union{\Left,\This}}
  57. \lElse{\Union{\This,\Left}}
  58. }
  59. \If{\Up \textcolor{red}{compatible with} \This}{
  60. \lIf{\Up $<$ \This}{\Union{\Up,\This}}
  61. \textcolor{orange}{\tcp{\This is put under \Up to keep tree as flat as possible}\label{cmt}}
  62. \lElse{\Union{\This,\Up}}
  63. \textcolor{orange}{\tcp*[h]{\This linked to \Up}\label{lelse}}
  64. }
  65. }
  66. \lForEach{element $e$ of the line $i$}{\FindCompress{p}}
  67. }
  68. \end{algorithm}
  69. \DecMargin{1em}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement