Skip to content
Snippets Groups Projects
Commit 2ea7aa9f authored by Nicolas M. Thiéry's avatar Nicolas M. Thiéry
Browse files

WIMS: exercice avec plusieurs programmes, et logique implantee en local; WIMS...

WIMS: exercice avec plusieurs programmes, et logique implantee en local; WIMS recoit un unique gros fichier main.oef
parent 5a186cd6
No related branches found
No related tags found
No related merge requests found
Showing with 185 additions and 58 deletions
main.oef: header.oef programs/guess-output/*.cpp footer.oef Makefile
cd programs/guess-output; make all.oef
cat header.oef programs/guess-output/all.oef footer.oef > main.oef
Randomization
Implement all the logic in WIMS
Onsite compilation and production of the output
Support for various programming languages, based on file extension
Selection of theme based on file prefix
CSS style sheet for colored syntax highlighting
\statement{
<p>
Quel affichage produit le programme C++ suivant? On donnera le
résultat sur une seule ligne, les éléments étant séparés par des
espaces.
\special{expandlines \code}
}
\answer{}{\output}{type=text}
\title{Deviner l'affichage d'un programme C++}
\description{Deviner l'affichage d'un programme C++}
\language{fr}
\niveau{U1}
\author{Nicolas M. Thiry}
\email{Nicolas.Thiery@u-psud.fr}
\format{html}
\title{Affichage d'un programme C++}
\language{fr}
\author{Nicolas M. Thiry}
\email{Nicolas.Thiery@u-psud.fr}
\format{html}
\text{programName=random(if-semicolon.cpp, function-max.cpp)}
\text{code= \programName issametext if-semicolon.cpp ?
#include <iostream>
using namespace std;
int main() {
int x = 1+2;
if ( x == 3 ); {
cout << "Bonjour!" << endl;
}
cout << "Au revoir." << endl;
return 0;
}
}
\text{code= \programName issametext function-max.cpp ?
#include <iostream>
using namespace std;
float max(float a, float b) {
if ( a >= b ) {
return a;
} else {
return b;
}
}
int main() {
cout << max(1.0, 3.0) << endl;
cout << max(5.0, 2.0) << endl;
cout << max(2.0, 2.0) << endl;
return 0;
}
}
\text{output=
42
}
\statement{
<p>
On considre le programme C++ suivant:
<hr>
<pre>
\special{expandlines \code}
</pre>
<hr>
}
\answer{Qu'affiche-t'il?}{\output}{type=text}
PROGRAMS=$(wildcard *.cpp)
HTML=$(PROGRAMS:%.cpp=%.html)
OUTPUT=$(PROGRAMS:%.cpp=%.output)
BASENAMES=$(PROGRAMS:%.cpp=%)
all: $(OUTPUT) $(HTML) filelist
%.output: %.bin
./$< > $@
%.bin: %.cpp
g++ $< -o $@
%.html: %.cpp
pygmentize -o $@ -O style=colorful $< # ,linenos=1
clean:
rm *.bin *.output *.html all.oef
all.oef: Makefile $(OUTPUT) $(HTML)
echo "\\\\text{programName=random("`ls -m *.cpp`")}" > $@
for basename in $(BASENAMES); do \
echo "\\\\text{code=\\programName issametext $$basename.cpp ?"; \
cat $$basename.html; \
echo "}"; \
echo "\\\\text{output=\\programName issametext $$basename.cpp ?"; \
cat $$basename.output; \
echo "}"; \
done >> $@
#include <iostream>
using namespace std;
int factorielle(int n) {
int resultat = 1;
for ( int k = 1; k <= n; k++ ) {
resultat = resultat * k;
}
return resultat;
}
int main() {
int n;
n = 4;
cout << n << "! = " << factorielle(n) << endl;
return 0;
}
#include <iostream>
using namespace std;
float max(float a, float b) {
if ( a >= b ) {
return a;
} else {
return b;
}
}
int main() {
cout << max(1.0, 3.0) << endl;
cout << max(5.0, 2.0) << endl;
cout << max(2.0, 2.0) << endl;
return 0;
}
......@@ -4,7 +4,7 @@ using namespace std;
int main() {
int x = 1+2;
if ( x == 3 ); {
cout << "Bonjour!" << endl;
cout << "Bonjour!" << endl;
}
cout << "Au revoir." << endl;
return 0;
......
#include <iostream>
using namespace std;
int main() {
int n, resultat;
n = 4;
resultat = 1;
do {
resultat = resultat * n;
n = n - 1;
} while (n > 0);
cout << resultat << endl;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n, resultat;
n=5;
resultat = 1;
for ( int k = 1; k <= n; k++ ) {
resultat = resultat * k;
}
cout << resultat << endl;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int n, resultat;
n = 3;
resultat = 1;
while (n > 0) {
resultat = resultat * n;
n = n - 1;
}
cout << resultat << endl;
return 0;
}
#include <iostream>
using namespace std;
int main() {
int a, b, c, d;
a = 0;
b = 0;
c = 0;
d = 0;
cout << a << " " << b << " " << c << " " << d << endl;
a = 1;
cout << a << " " << b << " " << c << " " << d << endl;
b = 3;
cout << a << " " << b << " " << c << " " << d << endl;
a + b;
cout << a << " " << b << " " << c << " " << d << endl;
a - b;
cout << a << " " << b << " " << c << " " << d << endl;
a = a + 2 * b;
cout << a << " " << b << " " << c << " " << d << endl;
c + b;
cout << a << " " << b << " " << c << " " << d << endl;
}
#include <iostream>
using namespace std;
int main() {
int resultat = 1;
resultat = resultat * 2;
resultat = resultat * 3;
resultat = resultat * 4;
resultat = resultat * 5;
resultat = resultat * 6;
resultat = resultat * 7;
cout << "Factorielle 7 vaut " << resultat << endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment