\documentclass[12pt,a4paper, onecolumn]{article}
\usepackage{ngerman}
\usepackage[latin1]{inputenc} % deutsche Umlaute tippen
\usepackage[pdftex]{color}
\usepackage[end]{algpseudocode}
\usepackage{listings}


\definecolor{darkblue}{rgb}{0,0,.6}
\definecolor{darkred}{rgb}{.6,0,0}
\definecolor{darkgreen}{rgb}{0,.6,0}
\definecolor{red}{rgb}{.98,0,0}
\definecolor{lightblue}{rgb}{0.8,0.85,1}

\oddsidemargin=-5mm
\evensidemargin=-5mm
\topmargin=-15mm
\headsep=10mm
\textwidth=170mm
\textheight=245mm

\lstloadlanguages{C++}
\lstset{%
  language=C++,
  basicstyle=\tiny
}%

\begin{document}
\section{Informatik und Programmieren}
\label{sec:InformatikUndProgrammieren}
\subsection{C++-Listings, Variante 1}
\label{sec:Listings}
Dies ist ein Quellcode im einfache Farbschema, mit der einzigen Änderung, dass die SChriftgröße auf \verb!\tiny! gestellt wurde.
\begin{lstlisting}[language=C++]
#include <iostream>

// Bubble-Sort für ein int-Feld
void SuperClass::bubble_sort(){
   if (N<=0) return;
   int temp;
   for (int i=N-1; i>=0; i--) {
      for (int j=1; j <= i; j++) {
         if ( data[j] < data[j-1] ) )
         {
             temp = data[j];
             data[j] = data[j-1];
             data[j-1] = temp;
             std::cout<<"exchanged "<<i<<" and "<<j<<std::endl
         }
      }
   }
}
\end{lstlisting}

\subsection{C++-Listings, Variante 2}
\label{sec:Listings2}
Dieser Quellcode wird in einem anderen Farbschema dargestellt, das sich an das Highlighting in vielen C++-Editoren anlehnt.

\lstset{%
  language=C++,
  basicstyle=\tiny\ttfamily,
  commentstyle=\itshape\color{darkgreen},
  keywordstyle=\bfseries\color{darkblue},
  stringstyle=\color{darkred},
  showspaces=false,
  showtabs=false,
  columns=fixed,
  numbers=left,
  frame=none,
  numberstyle=\tiny,
  breaklines=true,
  showstringspaces=false,
  xleftmargin=1cm
}%
\begin{lstlisting}[language=C++]
#include <iostream>

// Bubble-Sort für ein int-Feld
void SuperClass::bubble_sort(){
   if (N<=0) return;
   int temp;
   for (int i=N-1; i>=0; i--) {
      for (int j=1; j <= i; j++) {
         if ( data[j] < data[j-1] ) )
         {
             temp = data[j];
             data[j] = data[j-1];
             data[j-1] = temp;
             std::cout<<"exchanged "<<i<<" and "<<j<<std::endl
         }
      }
   }
}
\end{lstlisting}


\subsection{C++-Listings, Variante 3}
\label{sec:Listings3}
Dieser Quellcode wird in einem Farbschema mit Hintergrund blauem dargestellt.

\lstloadlanguages{C++}
\lstset{%
  language=C++,
  basicstyle=\tiny\ttfamily,
  commentstyle=\it,
  keywordstyle=\bf,
  stringstyle=\ttfamily,
  showspaces=false,
  showtabs=false,
  columns=fixed,
  backgroundcolor=\color{lightblue},
  numbers=left,
  frame=single,
  numberstyle=\tiny,
}%
\begin{lstlisting}[language=C++]
#include <iostream>

// Bubble-Sort für ein int-Feld
void SuperClass::bubble_sort(){
   if (N<=0) return;
   int temp;
   for (int i=N-1; i>=0; i--) {
      for (int j=1; j <= i; j++) {
         if ( data[j] < data[j-1] ) )
         {
             temp = data[j];
             data[j] = data[j-1];
             data[j-1] = temp;
             std::cout<<"exchanged "<<i<<" and "<<j<<std::endl
         }
      }
   }
}
\end{lstlisting}

\newpage
\subsection{Pascal-Listings}
\label{sec:Listings4}
\lstloadlanguages{Pascal}
\lstset{%
  basicstyle=\footnotesize\rmfamily,
  commentstyle=\footnotesize\itshape,
  backgroundcolor=\color{white},
  numbers=left,
  frame=none,
}%
\begin{lstlisting}[language=Pascal]
{ N: länge des Feldes a[1..N], das sortiert werden soll }
procedure BubbleSort;
var i,j:integer;
begin
  for i:=N downto 1 do begin
    for j:=2 to i do begin
      if a[j]<a[j-1] then 
        swap(a[j+1], a[j]);
    end;
  end;
end;
\end{lstlisting}




\newpage
\subsection{Algorithmicx}
\label{sec:Algorithmicx}
\begin{algorithmic}[1]
  \Function{EulerIntegrate}{$y_0, a, b, h, f(\cdot)$}
    \State $N\gets \frac{b-a}{h}$\Comment{Anzahl der Schritte berechnen}
    \State $y\gets y_0$
    \For{$i=1,...,N$}\Comment{eigentliche Integration}
      \State $y\gets y + h\cdot f(a+i\cdot h)$
    \EndFor
    \State\Return $y$
  \EndFunction
\end{algorithmic}


\end{document}


