2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-25 06:18:05 +02:00
This commit is contained in:
Martin Thoma 2014-03-09 19:06:23 +01:00
parent 25732f4421
commit a586fb4f77
8 changed files with 108 additions and 39 deletions

View file

@ -2,13 +2,15 @@
\chapter{C} \chapter{C}
\index{C|(} \index{C|(}
C ist eine imperative Programmiersprache. Sie wurde in vielen Standards C ist eine imperative Programmiersprache. Sie wurde in vielen Standards
definiert. Die wichtigsten davon sind:\todo{Wo sind unterschiede?} definiert. Die wichtigsten davon sind:
\begin{itemize} \begin{itemize}
\item C89 \item C89 wird auch ANSI C genannt.
\item C99 \item C90 wurde unter ISO 9899:1990 veröffentlicht. Es gibt keine bedeutenden
\item ANSI C Unterschiede zwischen C89 und C90, nur ist das eine ein ANSI-Standard
\item C11 und das andere ein ISO-Standard.
\item C99 wurde unter ISO 9899:1999 veröffentlicht.
\item C11 wurde unter ISO 9899:2011 veröffentlicht.
\end{itemize} \end{itemize}
\section{Datentypen}\xindex{Datentypen} \section{Datentypen}\xindex{Datentypen}
@ -28,49 +30,84 @@ Die grundlegenden C-Datentypen sind
zusätzlich kann man \texttt{char}\xindex{char} und \texttt{int}\xindex{int} zusätzlich kann man \texttt{char}\xindex{char} und \texttt{int}\xindex{int}
noch in \texttt{signed}\xindex{signed} und \texttt{unsigned}\xindex{unsigned} noch in \texttt{signed}\xindex{signed} und \texttt{unsigned}\xindex{unsigned}
unterscheiden. unterscheiden. Diese werden \textit{Modifier}\xindex{Modifier} genannt.
In C gibt es keinen direkten Support für Booleans.
\section{ASCII-Tabelle}\label{sec:ascii-tabelle} \section{ASCII-Tabelle}\label{sec:ascii-tabelle}
\begin{table}[htp] \begin{table}[h]
\centering \centering
\resizebox{0.65\textwidth}{!}{%
\begin{tabular}{|l|l||l|l||l|l||l|l|} \begin{tabular}{|l|l||l|l||l|l||l|l|}
\hline \hline
\textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} \\ \hline\hline \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} \\ \hline\hline
0 & ~ & 31 & ~ & 64 & @ & 96 & ' \\ \hline 0 & ~ & 32 & ~ & 64 & @ & 96 & ' \\ \hline
1 & ~ & ~ & ~ & 65 & A & 97 & a \\ \hline 1 & ~ & 33 & ! & 65 & A & 97 & a \\ \hline
2 & ~ & ~ & ~ & 66 & B & 98 & b \\ \hline 2 & ~ & 34 & " & 66 & B & 98 & b \\ \hline
3 & ~ & ~ & ~ & ~ & C & 99 & c \\ \hline 3 & ~ & 35 & \# & 67 & C & 99 & c \\ \hline
4 & ~ & ~ & ~ & ~ & D & 100 & d \\ \hline 4 & ~ & 36 & \$ & 68 & D & 100 & d \\ \hline
5 & ~ & ~ & ~ & ~ & E & ~ & ~ \\ \hline 5 & ~ & 37 & \% & 69 & E & 101 & e \\ \hline
6 & ~ & ~ & ~ & ~ & F & ~ & ~ \\ \hline 6 & ~ & 38 & \& & 70 & F & 102 & f \\ \hline
7 & ~ & ~ & ~ & ~ & G & ~ & ~ \\ \hline 7 & ~ & 39 & ' & 71 & G & 103 & g \\ \hline
8 & ~ & ~ & ~ & ~ & H & ~ & ~ \\ \hline 8 & ~ & 40 & ( & 72 & H & 104 & h \\ \hline
9 & ~ & ~ & ~ & ~ & I & ~ & ~ \\ \hline 9 & ~ & 41 & ) & 73 & I & 105 & i \\ \hline
10 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 10 & ~ & 42 & * & 74 & J & 106 & j \\ \hline
11 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 11 & ~ & 43 & + & 75 & K & 107 & k \\ \hline
12 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 12 & ~ & 44 & , & 76 & L & 108 & l \\ \hline
13 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 13 & ~ & 45 & - & 77 & M & 109 & m \\ \hline
14 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 14 & ~ & 46 & . & 78 & N & 110 & n \\ \hline
15 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 15 & ~ & 47 & / & 79 & O & 111 & o \\ \hline
16 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 16 & ~ & 48 & 0 & 80 & P & 112 & p \\ \hline
17 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 17 & ~ & 49 & 1 & 81 & Q & 113 & q \\ \hline
18 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 18 & ~ & 50 & 2 & 82 & R & 114 & r \\ \hline
19 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 19 & ~ & 51 & 3 & 83 & S & 115 & s \\ \hline
20 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 20 & ~ & 52 & 4 & 84 & T & 116 & t \\ \hline
21 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 21 & ~ & 53 & 5 & 85 & U & 117 & u \\ \hline
22 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 22 & ~ & 54 & 6 & 86 & V & 118 & v \\ \hline
23 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 23 & ~ & 55 & 7 & 87 & W & 119 & w \\ \hline
24 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 24 & ~ & 56 & 8 & 88 & X & 120 & x \\ \hline
25 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 25 & ~ & 57 & 9 & 89 & Y & 121 & y \\ \hline
26 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 26 & ~ & 58 & : & 90 & Z & 122 & z \\ \hline
27 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 27 & ~ & 59 & ; & 91 & $[$ & 123 & \{ \\ \hline
28 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 28 & ~ & 60 & < & 92 & \textbackslash & 124 & | \\ \hline
29 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline 29 & ~ & 61 & = & 93 & $]$ & 125 & \} \\ \hline
31 & ~ & ~ & ~ & ~ & ~ & 127 & ~ \\ \hline\hline 30 & ~ & 62 & > & 94 & \textasciicircum & 126 & $\sim$ \\ \hline
31 & ~ & 63 & ? & 95 & \_ & 127 & DEL \\ \hline
\end{tabular}
}
\end{table}
\section{Syntax}
\section{Präzedenzregeln}
\begin{tabbing}
\textbf{A} \=\enquote{[name] is a\dots}\\
\>\textbf{B.1} \=prenthesis {\color{red}$( )$}\\
\>\textbf{B.2} \>postfix operators:\\
\> \>\textbf{B.2.1} \={\color{red}$( )$} \=\enquote{\dots function returning\dots}\\
\> \>\textbf{B.2.2} \>{\color{red}$[ ]$} \>\enquote{\dots array of\dots}\\
\>\textbf{B.3} \>prefix operator: {\color{red}*} \enquote{\dots pointer to\dots}\\
\>\textbf{B.4} \>prefix operator {\color{red}*} and {\color{red}\texttt{const} / \texttt{volatile}} modifier:\\
\> \>\enquote{\dots [modifier] pointer to\dots}\\
\>\textbf{B.5} \>{\color{red}\texttt{const} / \texttt{volatile}} modifier next to type specifier:\\
\> \>\enquote{\dots [modifier] [specifier]}\\
\>\textbf{B.6} \>type specifier: \enquote{\dots [specifier]}
\end{tabbing}
\texttt{static unsigned int* const *(*next)();}
\begin{table}[htp]
\centering
\begin{tabular}{lll}
A & \texttt{next} & next is a \\
B.3 & \texttt{*} & \dots pointer to\dots \\
B.1 & \texttt{( )} & \dots \\
B.2.1 & \texttt{( )} & \dots a function returning\dots \\
B.3 & \texttt{*} & \dots pointer to\dots \\
B.4 & \texttt{*const} & \dots a read-only pointer to\dots \\
B.6 & \texttt{static unsigned int} & \dots static unsigned int. \\
\end{tabular} \end{tabular}
\end{table} \end{table}
\section{Syntax}
\section{Beispiele} \section{Beispiele}
\subsection{Hello World} \subsection{Hello World}
Speichere den folgenden Text als \texttt{hello-world.c}: Speichere den folgenden Text als \texttt{hello-world.c}:

View file

@ -149,6 +149,15 @@ Auch die gewohnten Operationen lassen sich so darstellen.
\end{align*} \end{align*}
\end{beispiel} \end{beispiel}
\begin{beispiel}[Vorgänger-Operation]
\begin{align*}
\pair&:= \lambda a. \lambda b. \lambda f. f a b\\
\fst &:= \lambda p. p (\lambda a. \lambda b. a)\\
\snd &:= \lambda p. p (\lambda a. \lambda b. b)\\
\nxt &:= \lambda p. \pair (\snd p)~(\succ (\snd p))\\
\pred&:= \lambda n. \fst (n \nxt (\pair c_0 c_0))
\end{align*}
\end{beispiel}
\begin{beispiel}[Addition] \begin{beispiel}[Addition]
\begin{align*} \begin{align*}
\text{plus} &:= \lambda m n f z. m f (n f z) \text{plus} &:= \lambda m n f z. m f (n f z)

View file

@ -28,6 +28,13 @@ Dabei wird eine \texttt{a.out} Datei erzeugt, die man wie folgt
nutzen kann: nutzen kann:
\inputminted[numbersep=5pt, tabsize=4]{bash}{scripts/prolog/human-2.sh} \inputminted[numbersep=5pt, tabsize=4]{bash}{scripts/prolog/human-2.sh}
\subsection{Splits}
\inputminted[linenos, numbersep=5pt, tabsize=4, frame=lines, label=splits.pl]{prolog}{scripts/prolog/splits.pl}
Dieses skript soll man \texttt{swipl -f test.pl} aufrufen. Dann erhält man:
\inputminted[numbersep=5pt, tabsize=4]{prolog}{scripts/prolog/splits.sh}
\subsection{Zebrarätsel} \subsection{Zebrarätsel}
Folgendes Rätsel wurde von \url{https://de.wikipedia.org/w/index.php?title=Zebrar%C3%A4tsel&oldid=126585006} Folgendes Rätsel wurde von \url{https://de.wikipedia.org/w/index.php?title=Zebrar%C3%A4tsel&oldid=126585006}
entnommen: entnommen:

View file

@ -13,6 +13,9 @@ Der Befehl \texttt{x10c++ hello-world.x10} erstellt eine ausführbare Datei name
\inputminted[numbersep=5pt, tabsize=4, frame=lines, label=hello-world.x10]{cpp}{scripts/x10/hello-world.x10} \inputminted[numbersep=5pt, tabsize=4, frame=lines, label=hello-world.x10]{cpp}{scripts/x10/hello-world.x10}
\section{Syntax} \section{Syntax}
\section{Datentypen}
Byte, UByte, Short, UShort, Char, Int, UInt, Long, ULong, Float, Double, Boolean, Complex, String, Point, Region, Dist, Array
\section{Beispiele} \section{Beispiele}
\section{Weitere Informationen} \section{Weitere Informationen}

View file

@ -0,0 +1,2 @@
splits(L, ([], L)).
splits([X|L], ([X|S], E)) :- splits(L, (S, E)).

View file

@ -0,0 +1,6 @@
? splits([1,2,3], Res).
Res = ([], [1,2,3]) ;
Res = ([1], [2,3]) ;
Res = ([1,2], [3]) ;
Res = ([1,2,3], []) ;
No

View file

@ -71,6 +71,11 @@
\DeclareMathOperator{\IWS}{IWS} \DeclareMathOperator{\IWS}{IWS}
\DeclareMathOperator{\SLL}{SLL} \DeclareMathOperator{\SLL}{SLL}
\DeclareMathOperator{\Bild}{Bild} \DeclareMathOperator{\Bild}{Bild}
\DeclareMathOperator{\fst}{fst}
\DeclareMathOperator{\snd}{snd}
\DeclareMathOperator{\pair}{pair}
\DeclareMathOperator{\nxt}{next}
\DeclareMathOperator{\pred}{pred}
\let\succ\relax% Set equal to \relax so that LaTeX thinks it's not defined \let\succ\relax% Set equal to \relax so that LaTeX thinks it's not defined
\DeclareMathOperator{\succ}{succ} \DeclareMathOperator{\succ}{succ}
\newcommand{\iu}{{i\mkern1mu}} % imaginary unit \newcommand{\iu}{{i\mkern1mu}} % imaginary unit