contents/computer_science.tex : added more code exemple

This commit is contained in:
saundersp 2024-07-11 22:46:09 +02:00
parent 70fa023190
commit b9ca4eaa67

View File

@ -12,7 +12,6 @@
\SetAlgoLined
\SetNoFillComment
\tcc{This is a comment}
\vspace{3mm}
some code here\;
$x \leftarrow 0$\;
$y \leftarrow 0$\;
@ -35,16 +34,28 @@ $y \leftarrow 0$\;
\caption{what}
\end{algorithm}
\langsection{Exemple en Haskell}{Haskell example}
\begin{lstlisting}[language=Haskell]
fibonacci :: Int -> Int
fibonacci 0 = 0
fibonacci 1 = 1
fibonacci n = fibonacci (n - 1) + fibonacci (n - 2)
\end{lstlisting}
\langsection{Exemple en Python}{Python example}
\begin{lstlisting}[language=Python]
def fnc(a, b):
return a + b
def fibonacci(n: int) -> int:
if n == 0 or n == 1:
return n
return fibonacci(n - 1) + fibonacci(n - 2)
\end{lstlisting}
\langsection{Exemple en C}{C example}
\begin{lstlisting}[language=C]
int fnc(int a, int b){
return a + b;
int fibonacci(const int n){
if (n == 0 || n == 1)
return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
\end{lstlisting}