von the_time » Sa 3. Okt 2015, 16:56
Hallo zusammen,
es geht mir um die erste Frage aber wenn jemand es weißt und Lust hat, kann er auch gerne die 2te und 3te Frage beantworten

.
1. wie kann ich Abstand zwischen dem Absatz und Algorithm sowie zwischen dem Algorithm und Listing hinzufügen?
2. wie kann ich Numierung zu den Algorithm-Zeilen hinzufügen?
3. wie kann ich comment im Algorithm schreiben?
Schöne Grüße,
the_time
Code
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\renewcommand{\baselinestretch}{1.5}
\usepackage{listings}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{algorithm}[H]
\SetAlgoLined
\KwData{$next\_id, speed,stop\_distance, mac$}
\KwResult{Find the initializer. }
int $next\_id1$ = find a record with $speed > 30$ \\ for this $mac$ in the next table;\\
int $next\_id2$ = find record with $speed <7$ and \\ $stop\_distance < 60$ for this mac in the next table;\\
\If{$next\_id1 < next\_id2$}{
find the related $stop\_name$ for this mac;\\
return $stop\_name$;
}
\caption{Algorithm to find intializer.}
\end{algorithm}
\begin{lstlisting}[caption = {MYSQL query to find the initializer.}, label={lst: initializer}]
SELECT speed, stop_name
from next
where stop_distance < 60 and speed < 7
and mac = ? and next_id > ? LIMIT 1
\end{lstlisting}
\clearpage
\end{document}
Hallo zusammen,
es geht mir um die erste Frage aber wenn jemand es weißt und Lust hat, kann er auch gerne die 2te und 3te Frage beantworten :) .
1. wie kann ich Abstand zwischen dem Absatz und Algorithm sowie zwischen dem Algorithm und Listing hinzufügen?
2. wie kann ich Numierung zu den Algorithm-Zeilen hinzufügen?
3. wie kann ich comment im Algorithm schreiben?
Schöne Grüße,
the_time
[b]Code[/b]
[code]
\documentclass{article}
\usepackage[ruled]{algorithm2e}
\renewcommand{\baselinestretch}{1.5}
\usepackage{listings}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{algorithm}[H]
\SetAlgoLined
\KwData{$next\_id, speed,stop\_distance, mac$}
\KwResult{Find the initializer. }
int $next\_id1$ = find a record with $speed > 30$ \\ for this $mac$ in the next table;\\
int $next\_id2$ = find record with $speed <7$ and \\ $stop\_distance < 60$ for this mac in the next table;\\
\If{$next\_id1 < next\_id2$}{
find the related $stop\_name$ for this mac;\\
return $stop\_name$;
}
\caption{Algorithm to find intializer.}
\end{algorithm}
\begin{lstlisting}[caption = {MYSQL query to find the initializer.}, label={lst: initializer}]
SELECT speed, stop_name
from next
where stop_distance < 60 and speed < 7
and mac = ? and next_id > ? LIMIT 1
\end{lstlisting}
\clearpage
\end{document}
[/code]