diff --git a/.gradebook.db b/.gradebook.db index c60e53a20176eecba0da221b4c90bd5ac0545e2c..6732b2cff54bc0f2a203e0e3e7ceb8e6a7cccc57 100644 Binary files a/.gradebook.db and b/.gradebook.db differ diff --git a/Makefile b/Makefile index b004eef783f74cc963e57c11866cfeac0918b2e5..b0a229664283175efa39147922efc2cc3c9cbbf8 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 0ff8fc2ed501c68bf7ccac7c5ef3b0e6b7dc4c83..f50869b3220824d579e43c199bdf7d1ec0bdcafd 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 2ac0b5ae0434fd6b7f3f5b9b75b71e4dbabda2c6..e75640789c92eddacf69ad4cfd05a9c5b74efa53 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 5959a549e4d8f382b01c44095f49736420bc2daa..673001be95820ebbd72708994ef9998c22ec656d 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 0aee0d2df1015f26c0940a29ad797b053c35a16b..2d3ce14fe3acfb787f24918394a71f1d32377ad2 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 70f3b674c0b9138ebe45e3649e4018c8aa4fa767..eaa8a0086965fd5ca04cc073e13b36c8c84af937 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 0000000000000000000000000000000000000000..c83292d68ff872c9db7a5e294eb2366a4d4bb2ee --- /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 0000000000000000000000000000000000000000..99fb29452519050826b1fc62ff8881a601e0828e --- /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 1ede182d5a7a574651da4ac957b54693a13146e0..3893c8f460026eb5d42f710faf2fe7c318367745 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 95ffdbc43fe6cb3f760bdfa3e98fecbfd721938b..be8a87bf65026f64ff64d9167fbcb420b6392702 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();