From 2073ce19784c9b7928ad2fb3a9ca0151bf7b6e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20M=2E=20Thi=C3=A9ry?= <nthiery@users.sf.net> Date: Mon, 27 Nov 2023 23:01:19 +0100 Subject: [PATCH] =?UTF-8?q?Pr=C3=A9paration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gradebook.db | Bin 196608 -> 196608 bytes Makefile | 4 +- cours-conclusion.md | 24 ----- .../for/cpp_forSommeCarre_code.md" | 2 +- .../cpp_prototype1_code.md" | 7 +- .../cpp_prototype2_code.md" | 6 +- .../cpp_prototype3_code.md" | 4 + .../cpp_prototype4_code.md" | 86 ++++++++++++++++++ .../cpp_prototype5_code.md" | 82 +++++++++++++++++ index.md | 1 - premier-dessin.cpp | 17 +++- 11 files changed, 194 insertions(+), 39 deletions(-) create mode 100644 "entra\303\256neur/function_prototype/cpp_prototype4_code.md" create mode 100644 "entra\303\256neur/function_prototype/cpp_prototype5_code.md" diff --git a/.gradebook.db b/.gradebook.db index c60e53a20176eecba0da221b4c90bd5ac0545e2c..6732b2cff54bc0f2a203e0e3e7ceb8e6a7cccc57 100644 GIT binary patch delta 89 zcmV-f0H*(dfDC|u43HZE(UBZO0nxEwtbYs+y$&M`{0wdj*AHj0fiw%VOp6@^0UWbx vk8TeI93%rx0h96LAhZ3RXAcM*Cj=2q0aQejp{^i<jIM`_t^v1<t^#yXg4ZB8 delta 89 zcmV-f0H*(dfDC|u43HZE&ygHM0nf2utbYs-XAZp%BMkfuZVT73fiw%VOp6@^0T#1r vk8TeI79;~r0h96LAhZ3RXAcM#Cj=2q0aQejp{^i<jIM`_t^v1<t^#yXeBB@- diff --git a/Makefile b/Makefile index b004eef..b0a2296 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ GRAPHIC_PROGS=$(wildcard exemple-graphisme*.cpp segment*.cpp cercle*.cpp premier-dessin*.cpp disque*.cpp souris*.cpp) -OTHER_PROGS=$(wildcard factorielle-*.cpp) fibonacci-exemple fibonacci-test +OTHER_PROGS=$(wildcard factorielle-*.cpp) fibonacci-exemple.cpp fibonacci-test.cpp programme1.cpp programme2.cpp max-test.cpp puissance4.cpp PROGS=$(GRAPHIC_PROGS) $(OTHER_PROGS) TARGET=$(PROGS:%.cpp=%) @@ -30,5 +30,5 @@ $(GRAPHIC_PROGS:%.cpp=%): %: %.o primitives.o $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ -lsfml-window -lsfml-graphics -lsfml-system clean: - -rm -rf $(TARGET) *.o + -rm -rf $(TARGET) *.o puissance-quatre.s diff --git a/cours-conclusion.md b/cours-conclusion.md index 0ff8fc2..f50869b 100644 --- a/cours-conclusion.md +++ b/cours-conclusion.md @@ -121,27 +121,3 @@ rise: </div> -```{code-cell} -:tags: [] - -double f(int, double) { - return 0; -} -``` - -```{code-cell} -:tags: [] - -#include <typeinfo> -``` - -```{code-cell} -:tags: [] - -typeid(f).name() -``` - -```{code-cell} - -``` - diff --git "a/entra\303\256neur/for/cpp_forSommeCarre_code.md" "b/entra\303\256neur/for/cpp_forSommeCarre_code.md" index 2ac0b5a..e756407 100644 --- "a/entra\303\256neur/for/cpp_forSommeCarre_code.md" +++ "b/entra\303\256neur/for/cpp_forSommeCarre_code.md" @@ -31,7 +31,7 @@ CONST I2 = RANDOM_INT(18, 26); :::{admonition} Consigne -Écrivez ici le code permettant de mettre dans la variable s +Écrivez ici le code permettant de mettre dans la variable `s` la somme des carrés des entiers compris entre I1 et I2 inclus. ::: diff --git "a/entra\303\256neur/function_prototype/cpp_prototype1_code.md" "b/entra\303\256neur/function_prototype/cpp_prototype1_code.md" index 5959a54..673001b 100644 --- "a/entra\303\256neur/function_prototype/cpp_prototype1_code.md" +++ "b/entra\303\256neur/function_prototype/cpp_prototype1_code.md" @@ -18,6 +18,8 @@ kernelspec: :tags: [hide-cell] #include <iostream> +#include <typeinfo> +#include <string> #include "jupyter_exercizer_helpers.hpp" using namespace std; @@ -32,7 +34,6 @@ nom de la fonction et son utilisation. ::: ```{code-cell} - /** Teste si a divise b * @param un entier a et un entier b * @return true si a divise b, false sinon @@ -54,7 +55,6 @@ bool estDiviseur(int a, int b) { /// END SOLUTION return b % a == 0; } - ``` ```{code-cell} @@ -65,8 +65,6 @@ estDiviseur(2,8) estDiviseur(3,8) ``` -+++ - ```{code-cell} --- editable: false @@ -79,6 +77,7 @@ nbgrader: solution: false tags: [hide-cell] --- +CHECK( typeid(estDiviseur).name() == string("FbiiE") ); CHECK( estDiviseur(2,8) ); CHECK( !estDiviseur(3,8) ); ``` diff --git "a/entra\303\256neur/function_prototype/cpp_prototype2_code.md" "b/entra\303\256neur/function_prototype/cpp_prototype2_code.md" index 0aee0d2..2d3ce14 100644 --- "a/entra\303\256neur/function_prototype/cpp_prototype2_code.md" +++ "b/entra\303\256neur/function_prototype/cpp_prototype2_code.md" @@ -18,6 +18,8 @@ kernelspec: :tags: [hide-cell] #include <iostream> +#include <typeinfo> +#include <string> #include "jupyter_exercizer_helpers.hpp" using namespace std; @@ -54,7 +56,6 @@ float produit(int a, float b) { /// END SOLUTION return a * b; } - ``` ```{code-cell} @@ -65,8 +66,6 @@ produit(3, 2.5) produit(2, 5.4) ``` -+++ - ```{code-cell} --- editable: false @@ -79,6 +78,7 @@ nbgrader: solution: false tags: [hide-cell] --- +CHECK( typeid(produit).name() == string("FfifE") or typeid(produit).name() == string("FdidE" )) CHECK( produit(3, 2.5) == 7.5f ); CHECK( produit(2, 5.4) == 10.8f ); ``` diff --git "a/entra\303\256neur/function_prototype/cpp_prototype3_code.md" "b/entra\303\256neur/function_prototype/cpp_prototype3_code.md" index 70f3b67..eaa8a00 100644 --- "a/entra\303\256neur/function_prototype/cpp_prototype3_code.md" +++ "b/entra\303\256neur/function_prototype/cpp_prototype3_code.md" @@ -18,7 +18,10 @@ kernelspec: :tags: [hide-cell] #include <iostream> +#include <typeinfo> +#include <string> #include "jupyter_exercizer_helpers.hpp" + using namespace std; ``` @@ -77,6 +80,7 @@ nbgrader: solution: false tags: [hide-cell] --- +CHECK( string(typeid(nbCaracteres).name()).find(string("FiNSt")) != string::npos ) CHECK( nbCaracteres("bonjour") == 7 ); CHECK( nbCaracteres("aujourd'hui") == 11 ); ``` diff --git "a/entra\303\256neur/function_prototype/cpp_prototype4_code.md" "b/entra\303\256neur/function_prototype/cpp_prototype4_code.md" new file mode 100644 index 0000000..c83292d --- /dev/null +++ "b/entra\303\256neur/function_prototype/cpp_prototype4_code.md" @@ -0,0 +1,86 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.15.2 +kernelspec: + display_name: C++17 + language: C++17 + name: xcpp17 +--- + +### Objectif pédagogique : écriture d'entête de fonction + +```{code-cell} +:editable: 'false' +:tags: [hide-cell] + +#include <iostream> +#include <typeinfo> +#include <string> +#include "jupyter_exercizer_helpers.hpp" + +using namespace std; +``` + +:::{admonition} Consigne + +Écrivez ci-dessous l'entête de la fonction en n'oubliant pas de finir +par `{`. Regardez les appels dans les cellules suivantes pour voir le +nom de la fonction et son utilisation. + +::: + +```{code-cell} + +/** Affiche le contenu d'un tableau d'entiers + * @param tab un tableau d'entiers + **/ +``` + +```{code-cell} +--- +editable: 'true' +nbgrader: + grade: 'false' + grade_id: init + locked: 'false' + schema_version: '3' + solution: 'true' +--- +/// BEGIN SOLUTION +void affiche(vector<int> tab) { +/// END SOLUTION + for (int i=0; i<tab.size(); i++) { + cout << tab[i]<<endl; + } +} + +``` + +```{code-cell} +affiche( {3,2,5} ) +``` + +```{code-cell} +affiche( {7,4} ) +``` + ++++ + +```{code-cell} +--- +editable: false +nbgrader: + grade: true + grade_id: check + locked: true + points: 1 + schema_version: 3 + solution: false +tags: [hide-cell] +--- +CHECK( string(typeid(affiche).name()).find(string("FvSt6vectorI")) != string::npos ) +``` diff --git "a/entra\303\256neur/function_prototype/cpp_prototype5_code.md" "b/entra\303\256neur/function_prototype/cpp_prototype5_code.md" new file mode 100644 index 0000000..99fb294 --- /dev/null +++ "b/entra\303\256neur/function_prototype/cpp_prototype5_code.md" @@ -0,0 +1,82 @@ +--- +jupytext: + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.15.2 +kernelspec: + display_name: C++17 + language: C++17 + name: xcpp17 +--- + +### Objectif pédagogique : écriture d'entête de fonction + +```{code-cell} +:editable: 'false' +:tags: [hide-cell] + +#include <iostream> +#include <typeinfo> +#include <string> +#include "jupyter_exercizer_helpers.hpp" + +using namespace std; +``` + +:::{admonition} Consigne + +Écrivez ci-dessous l'entête de la fonction en n'oubliant pas de finir +par `{`. Regardez les appels dans les cellules suivantes pour voir le +nom de la fonction et son utilisation. + +::: + +```{code-cell} + +/** Affiche un compte à rebours commençant par l'entier pris en paramètre + * @param n un entier + **/ +``` + +```{code-cell} +--- +editable: 'true' +nbgrader: + grade: 'false' + grade_id: init + locked: 'false' + schema_version: '3' + solution: 'true' +--- +/// BEGIN SOLUTION +void afficheCompteARebours(int n) { +/// END SOLUTION + for (int i=n; i>=0; i--) { + cout << i << endl; + } +} + +``` + +```{code-cell} +afficheCompteARebours(5) +``` + ++++ + +```{code-cell} +--- +editable: false +nbgrader: + grade: true + grade_id: check + locked: true + points: 1 + schema_version: 3 + solution: false +tags: [hide-cell] +--- +CHECK( typeid(afficheCompteARebours).name() == string("FviE") ); +``` diff --git a/index.md b/index.md index 1ede182..3893c8f 100644 --- a/index.md +++ b/index.md @@ -327,4 +327,3 @@ de points sera ensuite affiché. À vous de concevoir les fonctions à introduire pour décomposer le problème. - diff --git a/premier-dessin.cpp b/premier-dessin.cpp index 95ffdbc..be8a87b 100644 --- a/premier-dessin.cpp +++ b/premier-dessin.cpp @@ -7,7 +7,7 @@ using namespace std; // Pour les exceptions dans la version distribuée int main() { int delai = 1; - RenderWindow window(VideoMode(900, 480), "Ma super fenêtre"); + RenderWindow window(VideoMode(640, 480), "Ma super fenêtre"); window.clear(Color::Green); // Dessine un point noir de coordonnées (418, 143) @@ -61,22 +61,31 @@ int main() { throw runtime_error("code non implanté ligne 56"); + window.display(); + sleep(seconds(delai)); + + // Dessine un triangle bleu entre les (0,0), (640,0) et (0,160) + + + // Remplacez cette ligne et la suivante par le code adéquat + throw runtime_error("code non implanté ligne 65"); + window.display(); sleep(seconds(delai)); // Dessine un cercle noir de centre (415,145) et de rayon 10 // Remplacez cette ligne et la suivante par le code adéquat - throw runtime_error("code non implanté ligne 64"); + throw runtime_error("code non implanté ligne 72"); window.display(); sleep(seconds(delai)); - // Dessine un disque jaune de centre (700, 100) et de rayon 50 + // Dessine un disque jaune de centre (550, 75) et de rayon 50 // Remplacez cette ligne et la suivante par le code adéquat - throw runtime_error("code non implanté ligne 72"); + throw runtime_error("code non implanté ligne 80"); window.display(); -- GitLab