From c225693e35dc32576d5e75316a57f0a7f7efc76a Mon Sep 17 00:00:00 2001 From: gwen Date: Mon, 29 May 2017 14:29:23 +0200 Subject: [PATCH] premiers sujets de tp --- algorithmique/markup.txt | 102 --------------------------------------- algorithmique/tp.txt | 67 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 102 deletions(-) delete mode 100644 algorithmique/markup.txt create mode 100644 algorithmique/tp.txt diff --git a/algorithmique/markup.txt b/algorithmique/markup.txt deleted file mode 100644 index fc60a06..0000000 --- a/algorithmique/markup.txt +++ /dev/null @@ -1,102 +0,0 @@ -markup -======== - -exercices ---------- - - -.. ifconfig:: exercice - - **Exercice** : - -.. ifconfig:: correction - - **Correction** : - - -sphinx ------------ - -.. function:: spam(eggs) - ham(eggs) - - Spam or ham the foo. - -The function :func:`spam` does a similar thing - - -http://www.sphinx-doc.org/en/stable/markup/code.html - -http://www.sphinx-doc.org/en/stable/domains.html - -latex --------------- - -s'il faut mettre du latex : - -https://www.jujens.eu/posts/2014/Aug/13/rapport-rst-sphinx/ - -(pour le preamble) - - -.. role:: latex(raw) - :format: latex - ----- - -sudo apt-get install texlive-full - - -You need to remove - -\usepackage{algorithmicx} - -and use the following in your preamble: - -\usepackage{algorithm}% http://ctan.org/pkg/algorithms -\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx - - -.. raw:: latex - - \begin{algorithm} - \caption{My algorithm}\label{euclid} - \begin{algorithmic}[1] - \Procedure{MyProcedure}{} - \State $\textit{stringlen} \gets \text{length of }\textit{string}$ - \State $i \gets \textit{patlen}$ - \BState \emph{top}: - \If {$i > \textit{stringlen}$} \Return false - \EndIf - \State $j \gets \textit{patlen}$ - \BState \emph{loop}: - \If {$\textit{string}(i) = \textit{path}(j)$} - \State $j \gets j-1$. - \State $i \gets i-1$. - \State \textbf{goto} \emph{loop}. - \State \textbf{close}; - \EndIf - \State $i \gets - i+\max(\textit{delta}_1(\textit{string}(i)),\textit{delta}_2(j))$. - \State \textbf{goto} \emph{top}. - \EndProcedure - \end{algorithmic} - \end{algorithm} - - -.. raw:: latex - - \begin{algorithm} - \caption{Euclid's algorithm}\label{euclid} - \begin{algorithmic}[1] - \Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b} - \State $r\gets a\bmod b$ - \While{$r\not=0$}\Comment{We have the answer if r is 0} - \State $a\gets b$ - \State $b\gets r$ - \State $r\gets a\bmod b$ - \EndWhile\label{euclidendwhile} - \State \textbf{return} $b$\Comment{The gcd is b} - \EndProcedure - \end{algorithmic} - \end{algorithm} diff --git a/algorithmique/tp.txt b/algorithmique/tp.txt new file mode 100644 index 0000000..a3ebdb4 --- /dev/null +++ b/algorithmique/tp.txt @@ -0,0 +1,67 @@ +Ecrire un algorithme qui renvoie le résultat d’une mini-calculatrice. Cette +méthode aura +comme paramètre deux nombres et une chaîne de caractère qui vaudra « + », « - +», « * », +« / ». + +--- + +Ecrire un algorithme qui renvoie si deux mots (chaîne de caractères) passés en +paramètre +sont des anagrammes l’un de l’autre. (Lettres identiques mais dans un ordre +différent) + +---- + +code de césar +(code de gray) + +---- +ascii art (ligne d'étoiles) + +Concevoir un algorithme qui, pour un caractère imprimable et un nombre n +donnés, imprime une barre +horizontale de n de ces caractères. +**************** +2. Modifier l’algorithme pour l’impression d’une barre double. +**************** +**************** + +3. Modifier l’algorithme pour l’impression d’une barre d’épaisseur quelconque +donnée. +4. (optionnel) Transformer les algorithmes ci-dessus en fonctions. +5. Écrire un programme Java implémentant la dernière version de l’algorithme +(épaisseur quelconque). + +3.3 +Triangle de nombres +Concevoir un algorithme qui imprime pour n donné : +1 +1 2 +1 2 3 +1 2 3 4 +1 2 3 4 5 +........... +............. +............... +1 2 3 4 5 6 ... n + + +écrire “Entrer un numéro de mois” +mois ← lire +selon que mois est +cas 1 : écrire “janvier (31 jours)” +cas 2 : écrire “février (28 ou 29 jours)” +cas 3 : écrire “mars (31 jours)” +cas 4 : écrire “avril (30 jours)” +cas 5 : écrire “mai (31 jours)” +cas 6 : écrire “juin (30 jours)” +cas 7 : écrire “juillet (31 jours)” +cas 8 : écrire “août (31 jours)” +cas 9 : écrire “septembre (30 jours)” +cas 10 : écrire “octobre (31 jours)” +cas 11 : écrire “novembre (30 jours)” +cas 12 : écrire “décembre (31 jours)” +défaut : écrire “numéro invalide” +fselon +