Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (5)
Showing
with 1194 additions and 4 deletions
No preview for this file type
GRAPHIC_PROGS=$(wildcard exemple-graphisme*.cpp segment*.cpp cercle*.cpp premier-dessin*.cpp disque*.cpp souris*.cpp) 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) PROGS=$(GRAPHIC_PROGS) $(OTHER_PROGS)
TARGET=$(PROGS:%.cpp=%) TARGET=$(PROGS:%.cpp=%)
...@@ -30,5 +30,5 @@ $(GRAPHIC_PROGS:%.cpp=%): %: %.o primitives.o ...@@ -30,5 +30,5 @@ $(GRAPHIC_PROGS:%.cpp=%): %: %.o primitives.o
$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ -lsfml-window -lsfml-graphics -lsfml-system $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ -lsfml-window -lsfml-graphics -lsfml-system
clean: clean:
-rm -rf $(TARGET) *.o -rm -rf $(TARGET) *.o puissance-quatre.s
...@@ -208,6 +208,7 @@ monMax(1,3) ...@@ -208,6 +208,7 @@ monMax(1,3)
slideshow: slideshow:
slide_type: fragment slide_type: fragment
--- ---
using namespace std;
monMax(string("toot"), string("alfred")) monMax(string("toot"), string("alfred"))
``` ```
......
...@@ -286,7 +286,7 @@ int monMax(int a, int b); ...@@ -286,7 +286,7 @@ int monMax(int a, int b);
- Si cette définition n'existe pas ou n'est pas unique, une erreur est - Si cette définition n'existe pas ou n'est pas unique, une erreur est
déclenchée par le compilateur déclenchée par le compilateur
- Cette erreur est déclenchée au moment où l'on combine les différents - Cette erreur est déclenchée au moment où l'on combine les différents
fichiers: voir plus loin «Édition de liens» fichiers : voir plus loin «Édition de liens»
+++ {"slideshow": {"slide_type": "fragment"}} +++ {"slideshow": {"slide_type": "fragment"}}
...@@ -405,7 +405,7 @@ Utiliser la bibliothèque `max` ...@@ -405,7 +405,7 @@ Utiliser la bibliothèque `max`
- Équivalent à copier-coller le contenu de `max.hpp` à l'emplacement du - Équivalent à copier-coller le contenu de `max.hpp` à l'emplacement du
`#include "max.hpp"` `#include "max.hpp"`
- ♣ Géré par le préprocesseur (cpp) - ♣ Géré par le préprocesseur (cpp)
``` :::
+++ {"slideshow": {"slide_type": "slide"}} +++ {"slideshow": {"slide_type": "slide"}}
......
File added
---
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 : division entière
```{code-cell}
:editable: false
:tags: [hide-cell]
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell}
:tags: [hide-cell, variable]
CONST I1 = RANDOM_CHOICE(3, 5, 7);
I1
```
+++
```{code-cell}
:tags: [hide-cell, variable]
CONST I3 = RANDOM_CHOICE(1, 2, 4, 8, 11, 13, 16, 17, 19, 22);
I3
```
+++
```{code-cell}
:tags: [hide-output, substitution]
int r;
r = I3 / I1;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
int result = INPUT(
/// BEGIN SOLUTION
I3 / I1
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
---
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 : reste de la division entière
```{code-cell}
:editable: false
:tags: [hide-cell]
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell}
:tags: [hide-cell, variable]
CONST I1 = RANDOM_CHOICE(3, 5, 7);
I1
```
+++
```{code-cell}
:tags: [hide-cell, variable]
CONST I3 = RANDOM_CHOICE(1, 2, 4, 8, 11, 13, 16, 17, 19, 22);
I3
```
+++
```{code-cell}
:tags: [hide-output, substitution]
int r;
r = I3 % I1;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
int result = INPUT(
/// BEGIN SOLUTION
I3 % I1
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
---
jupyter:
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: C++17
language: C++17
name: xcpp17
---
### Objectif pédagogique : priorité des opérations
```{code-cell} c++
---
editable: false
tags: [hide-cell]
---
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I1 = RANDOM_INT(1, 7);
I1
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I2 = RANDOM_INT(5, 12);
I2
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I3 = RANDOM_INT(1, 7);
I3
```
+++
```{code-cell} c++
---
tags: [hide-output,substitution]
---
int r;
r = I2 + I1 * I3;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
int result = INPUT(
/// BEGIN SOLUTION
I2 + I1 * I3
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
---
jupyter:
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: C++17
language: C++17
name: xcpp17
---
### Objectif pédagogique : priorité des opérations
```{code-cell} c++
---
editable: false
tags: [hide-cell]
---
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I1 = RANDOM_INT(1, 5);
I1
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I2 = RANDOM_INT(1, 3);
I2
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I3 = RANDOM_INT(1, 7);
I3
```
+++
```{code-cell} c++
---
tags: [hide-output,substitution]
---
int r;
r = (I2 PLUSOUMOINS I1) * I3;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
int result = INPUT(
/// BEGIN SOLUTION
(I2 PLUSOUMOINS I1) * I3
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
---
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 : alternative aux parenthèses
```{code-cell}
:editable: false
:tags: [hide-cell]
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell}
:tags: [hide-cell, variable]
CONST I1 = RANDOM_INT(1, 5);
CONST I2 = RANDOM_INT(1, 7);
CONST I3 = RANDOM_INT(1, 5);
```
+++
```{code-cell}
:tags: [hide-output, substitution]
int I, J, K, N;
I = I2 - I1;
J = I3 + I2;
K = I * J;
N = I2 - I1 * I3 + I2;
bool r = K == N;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
bool result = INPUT(
/// BEGIN SOLUTION
r
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
#ifndef RANDOMIZATION_H
#define RANDOMIZATION_H
#include <iostream>
#include <cstdlib>
#include <vector>
#include <functional>
/** Infrastructure minimale de test **/
#ifndef ASSERT
#define ASSERT(test) if (!(test)) { throw std::runtime_error("\\x1b[48;5;224mTest failed: "#test); }
#endif
#ifndef CHECK
#define CHECK(test) if ( !(test) ) { throw std::runtime_error("\\x1b[48;5;224mTest failed: "#test); }
#endif
// TODO: how to initialize the seed?
// TODO: randomize ???
#define PLUSOUMOINS +
#define CONST const auto
// TODO: randomize ???
#define X x
#define Y y
#define Z z
int RANDOM_INT(int min, int max) {
return min + (rand() % (max - min + 1));
}
template<typename T, typename ... Args>
T RANDOM_CHOICE(const T arg0, const Args... args) {
const std::vector<T> v({arg0, args...});
return v[rand() % v.size()];
}
template<typename ... Args>
auto RANDOM_CHOICE(const char * arg0, const Args... args) {
const std::vector<std::string> v({arg0, args...});
return v[rand() % v.size()];
}
class RANDOM_VECTOR_CLASS {
public:
template <typename F, typename ... Args>
auto operator ()(int N, F f, Args ... args) {
using invoke_result_t = typename std::invoke_result<F, Args ...>::type;
std::vector<invoke_result_t> v(N);
for (auto &value: v)
value = f(args...);
return v;
}
/*template<typename ... Args>
auto operator ()(int N, RANDOM_VECTOR_CLASS f, Args... args) {
std::vector<std::vector<int>> v(N);
for (auto &value: v)
value = f(args...);
return v;
}*/
};
RANDOM_VECTOR_CLASS RANDOM_VECTOR;
template<typename T>
std::ostream & operator << (std::ostream& o, const std::vector<T> &v) {
o << "{";
if ( v.size() >= 0 ) {
o << v[0];
for ( unsigned int i=1; i<v.size(); i++ )
o << ", " << v[i];
}
o << "}";
return o;
}
template<class T>
T INPUT(T t) {
return t;
}
#endif
from typing import Any
from random import randint, choice
CONST = Any
def INPUT(default: Any) -> Any:
return default
def RANDOM_INT(min: int, max: int):
return randint(min, max+1)
def RANDOM_CHOICE(*args):
r"""
Return a random element of `args`
>>> RANDOM_CHOICE("alice", "bob", "charlie") # doctest: +SKIP
'charlie'
>>> RANDOM_CHOICE("alice")
'alice'
"""
return choice(args)
---
jupyter:
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: C++17
language: C++17
name: xcpp17
---
### Objectif pédagogique : opération "and"
```{code-cell} c++
---
editable: false
tags: [hide-cell]
---
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I1 = RANDOM_INT(3, 9);
I1
```
+++
```{code-cell} c++
---
tags: [hide-output, substitution]
---
int x = I1;
bool r = x >= 0 and x <= 2;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
bool result = INPUT(
/// BEGIN SOLUTION
r
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
---
jupyter:
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: C++17
language: C++17
name: xcpp17
---
### Objectif pédagogique : opération "or"
```{code-cell} c++
---
editable: false
tags: [hide-cell]
---
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST I1 = RANDOM_INT(-1, 4);
I1
```
+++
```{code-cell} c++
---
tags: [hide-output, substitution]
---
int x = I1;
bool r = x < 0 or x > 2;
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
bool result = INPUT(
/// BEGIN SOLUTION
r
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```
#ifndef RANDOMIZATION_H
#define RANDOMIZATION_H
#include <iostream>
#include <cstdlib>
#include <vector>
#include <functional>
/** Infrastructure minimale de test **/
#ifndef ASSERT
#define ASSERT(test) if (!(test)) { throw std::runtime_error("\\x1b[48;5;224mTest failed: "#test); }
#endif
#ifndef CHECK
#define CHECK(test) if ( !(test) ) { throw std::runtime_error("\\x1b[48;5;224mTest failed: "#test); }
#endif
// TODO: how to initialize the seed?
// TODO: randomize ???
#define PLUSOUMOINS +
#define CONST const auto
// TODO: randomize ???
#define X x
#define Y y
#define Z z
int RANDOM_INT(int min, int max) {
return min + (rand() % (max - min + 1));
}
template<typename T, typename ... Args>
T RANDOM_CHOICE(const T arg0, const Args... args) {
const std::vector<T> v({arg0, args...});
return v[rand() % v.size()];
}
template<typename ... Args>
auto RANDOM_CHOICE(const char * arg0, const Args... args) {
const std::vector<std::string> v({arg0, args...});
return v[rand() % v.size()];
}
class RANDOM_VECTOR_CLASS {
public:
template <typename F, typename ... Args>
auto operator ()(int N, F f, Args ... args) {
using invoke_result_t = typename std::invoke_result<F, Args ...>::type;
std::vector<invoke_result_t> v(N);
for (auto &value: v)
value = f(args...);
return v;
}
/*template<typename ... Args>
auto operator ()(int N, RANDOM_VECTOR_CLASS f, Args... args) {
std::vector<std::vector<int>> v(N);
for (auto &value: v)
value = f(args...);
return v;
}*/
};
RANDOM_VECTOR_CLASS RANDOM_VECTOR;
template<typename T>
std::ostream & operator << (std::ostream& o, const std::vector<T> &v) {
o << "{";
if ( v.size() >= 0 ) {
o << v[0];
for ( unsigned int i=1; i<v.size(); i++ )
o << ", " << v[i];
}
o << "}";
return o;
}
template<class T>
T INPUT(T t) {
return t;
}
#endif
from typing import Any
from random import randint, choice
CONST = Any
def INPUT(default: Any) -> Any:
return default
def RANDOM_INT(min: int, max: int):
return randint(min, max+1)
def RANDOM_CHOICE(*args):
r"""
Return a random element of `args`
>>> RANDOM_CHOICE("alice", "bob", "charlie") # doctest: +SKIP
'charlie'
>>> RANDOM_CHOICE("alice")
'alice'
"""
return choice(args)
import random
import re
from typing import Dict, Tuple
from jupyter_exercizer_helpers import RANDOM_INT, RANDOM_CHOICE
STRING_QUOTE = '"'
VECTOR_OPEN = "{"
VECTOR_CLOSE = "}"
def_regexp = {
"C++": r"CONST\s+(\w+)\s+=\s+(.*?);?\s*$",
"python": r"(\w+):\s+CONST\s+=\s+(.*?);?\s*$"
}
for language in ['C++11', 'C++14', 'C++17']:
def_regexp[language] = def_regexp['C++']
def to_language(value):
"""
Return `value` as a string representing a C++ constant
.. TODO:: make the output language configurable
>>> to_language(3)
'3'
>>> to_language("alice")
'"alice"'
>>> to_language([1,2,3])
'{1, 2, 3}'
>>> to_language([[1,2],["alice", "bob"]])
'{{1, 2}, {"alice", "bob"}}'
"""
if isinstance(value, str):
if value == "REF":
return "&"
if value == "VAL":
return ""
return STRING_QUOTE + value + STRING_QUOTE
elif isinstance(value, list):
return VECTOR_OPEN + ", ".join(to_language(v) for v in value) + VECTOR_CLOSE
else:
return str(value)
def RANDOM_VECTOR(n, generator, *args):
r"""
Return a random vector of length `n` and whose elements are
generated by calling `generator(*args)`
This return a random vector of integers of length 5, with
elements between 1 and 3:
>>> RANDOM_VECTOR(5, RANDOM_INT, 1, 3) # doctest: +SKIP
[3, 1, 2, 1, 3]
>>> RANDOM_VECTOR(5, RANDOM_INT, 1, 1)
[1, 1, 1, 1, 1]
"""
return [generator(*args) for i in range(n)]
def RANDOM_VALOUREF():
r"""
pas sur que ce soit la meilleur des methodes....
"""
return str(random.choice(["REF", "VAL"]))
locals = {
"RANDOM_INT": RANDOM_INT,
"RANDOM_CHOICE": RANDOM_CHOICE,
"RANDOM_VECTOR": RANDOM_VECTOR,
"RANDOM_VALOUREF": RANDOM_VALOUREF,
}
test_code = """CONST N = RANDOM_INT(3,3);
CONST M = RANDOM_INT(4,4);
CONST V = RANDOM_VECTOR(N, RANDOM_INT, 5, 5);
CONST VV = RANDOM_VECTOR(N, RANDOM_VECTOR, M, RANDOM_INT, 1, 1);
int main () {
int a = N + M;
vector<int> v = V;
vector<vector<int>> vv = VV;
}"""
class Randomizer:
def __init__(self, language='C++'):
consts = {}
consts["R"], consts["S"], consts["T"] = random.sample("rst", 3)
consts["X"], consts["Y"], consts["Z"] = random.sample("xyz", 3)
consts["I"], consts["J"], consts["K"], consts["N"] = random.sample("ijkn", 4)
consts["PLUSOUMOINS"] = str(random.choice(["+", "-"]))
consts["NAME"] = str(
random.choice(
["Alexandre", "Yasmine", "Albert", "Alice", "Antoine", "Anna"]
)
)
self.consts = consts
self.def_regexp = re.compile(def_regexp[language])
def randomize(self, text: str, is_code: bool = True) -> str:
result = []
for line in text.splitlines():
pattern = re.compile(r"\b(" + "|".join(self.consts.keys()) + r")\b")
if is_code:
match = re.match(self.def_regexp, line)
else:
match = None
if match:
# Define new constant
variable, value = match.groups()
# Substitutes all constants in the value
value = pattern.sub(lambda i: self.consts[i.group()], value)
# Evaluates the value in a context containing all the RANDOM_*
# functions
self.consts[variable] = to_language(eval(value, {}, locals))
else:
# Substitutes all constants
line = pattern.sub(lambda i: self.consts[i.group()], line)
result.append(line)
return "\n".join(result)
def randomize_code(code: str) -> Tuple[str, Dict]:
r"""
Randomize the given code
Examples:
>>> import random
>>> random.seed(0)
>>> randomize_code("int XX=3;")[0]
'int XX=3;'
>>> randomize_code("int X=3; int Y=4; int Z=5;")[0]
'int z=3; int x=4; int y=5;'
>>> randomize_code("I, J, K, N")[0]
'n, k, j, i'
>>> randomize_code("int X=1;\nint Y=2;")[0]
'int z=1;\nint y=2;'
>>> print(test_code)
CONST N = RANDOM_INT(3,3);
CONST M = RANDOM_INT(4,4);
CONST V = RANDOM_VECTOR(N, RANDOM_INT, 5, 5);
CONST VV = RANDOM_VECTOR(N, RANDOM_VECTOR, M, RANDOM_INT, 1, 1);
int main () {
int a = N + M;
vector<int> v = V;
vector<vector<int>> vv = VV;
}
>>> print(randomize_code(test_code)[0])
int main () {
int a = 3 + 4;
vector<int> v = {5, 5, 5};
vector<vector<int>> vv = {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}};
}
"""
randomizer = Randomizer()
code = randomizer.randomize(code)
return code, randomizer.consts
---
jupytext:
text_representation:
extension: .md
format_name: myst
format_version: 0.13
kernelspec:
display_name: Python 3 (ipykernel)
language: python
name: python3
---
# Exercices d'entraînement
Exécutez la cellule suivante, puis choisissez le thème sur lequel
vous souhaitez vous entraîner.
```{code-cell} ipython3
---
editable: true
slideshow:
slide_type: ''
---
from entraîneur import entraîneur
entraîneur
```
```{code-cell} ipython3
```
import glob
from ipywidgets import interactive # type: ignore
from jupyter_exercizer import Exercizer
from IPython.display import display
thèmes = {
'variable': 'Variables',
'arithmetic': 'Arithmétique',
'bool': 'Expressions booléennes',
'for': 'Boucles for',
'while': 'Boucles while',
'function_prototype': 'Prototypes de fonctions',
}
def entraîneur(Thème=[(a, b) for b, a in thèmes.items()]):
exercizes = glob.glob(f"{Thème}/*.md")
display(Exercizer(exercizes))
entraîneur = interactive(entraîneur)
---
jupyter:
jupytext:
text_representation:
extension: .md
format_name: myst
kernelspec:
display_name: C++17
language: C++17
name: xcpp17
---
### Objectif pédagogique : accumulateur avec boucle for
```{code-cell} c++
---
editable: false
tags: [hide-cell]
---
#include <iostream>
#include "jupyter_exercizer_helpers.hpp"
using namespace std;
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST RINIT = RANDOM_INT(1, 7);
RINIT
```
+++
```{code-cell} c++
---
tags: [hide-cell, variable]
---
CONST IMAX = RANDOM_INT(2, 4);
IMAX
```
+++
```{code-cell} c++
---
tags: [hide-output, substitution]
---
int r = RINIT;
for ( int I = 1; I <= IMAX ; I = I + 1 ) {
r = r + I;
}
```
+++
:::{admonition} Consigne
Quelle est la valeur attendue de `r`?
:::
```{code-cell}
---
editable: true
nbgrader:
grade: false
grade_id: init
locked: false
schema_version: 3
solution: true
---
int result = INPUT(
/// BEGIN SOLUTION
r
/// END SOLUTION
);
```
+++
```{code-cell}
---
editable: false
nbgrader:
grade: true
grade_id: check
locked: true
points: 1
schema_version: 3
solution: false
tags: [hide-cell]
---
CHECK( result == r );
```