From 44b2c81edc51606d553c2c2ccab57741c1117d94 Mon Sep 17 00:00:00 2001 From: Viviane Pons <vivianepons@gmail.com> Date: Tue, 30 Sep 2014 18:45:38 +0200 Subject: [PATCH] Ajout exos Wims --- .../guess-output/function-blackjack.cpp | 42 +++++++++++++++++++ oef/programs/guess-output/loop-indices-2.cpp | 12 ++++++ oef/programs/guess-output/loop-indices.cpp | 12 ++++++ oef/programs/guess-output/loop-syracuse.cpp | 14 +++++++ 4 files changed, 80 insertions(+) create mode 100644 oef/programs/guess-output/function-blackjack.cpp create mode 100644 oef/programs/guess-output/loop-indices-2.cpp create mode 100644 oef/programs/guess-output/loop-indices.cpp create mode 100644 oef/programs/guess-output/loop-syracuse.cpp diff --git a/oef/programs/guess-output/function-blackjack.cpp b/oef/programs/guess-output/function-blackjack.cpp new file mode 100644 index 0000000..052bd34 --- /dev/null +++ b/oef/programs/guess-output/function-blackjack.cpp @@ -0,0 +1,42 @@ +#include <iostream> +using namespace std; + +int max(int x, int y) { + if(x > y) { + return x; + } + return y; +} + +int blackJack(int x, int y) { + if(x > 21) { + if(y > 21) { + return 0; + } + return y; + } + if (y > 21) { + return x; + } + return max(x,y); +} + + +int main() { + int x,y; + + x = 15; + y = 22; + cout << max(x,y) << endl; + cout << blackJack(x,y) << endl; + + x = 12; + y = 17; + cout << max(x,y) << endl; + cout << blackJack(x,y) << endl; + + x = 23; + y = 25; + cout << max(x,y) << endl; + cout << blackJack(x,y) << endl; +} diff --git a/oef/programs/guess-output/loop-indices-2.cpp b/oef/programs/guess-output/loop-indices-2.cpp new file mode 100644 index 0000000..b4a69a9 --- /dev/null +++ b/oef/programs/guess-output/loop-indices-2.cpp @@ -0,0 +1,12 @@ +#include <iostream> +using namespace std; + +int main() { + int i = 1; + + while(i < 11) { + cout << i << endl; + i = i * 2; + } + +} diff --git a/oef/programs/guess-output/loop-indices.cpp b/oef/programs/guess-output/loop-indices.cpp new file mode 100644 index 0000000..71ace57 --- /dev/null +++ b/oef/programs/guess-output/loop-indices.cpp @@ -0,0 +1,12 @@ +#include <iostream> +using namespace std; + +int main() { + int i = 0; + + while(i < 11) { + cout << i << endl; + i = i + 2; + } + +} diff --git a/oef/programs/guess-output/loop-syracuse.cpp b/oef/programs/guess-output/loop-syracuse.cpp new file mode 100644 index 0000000..0f6e433 --- /dev/null +++ b/oef/programs/guess-output/loop-syracuse.cpp @@ -0,0 +1,14 @@ +#include <iostream> +using namespace std; + +int main() { + int i = 6; + while(i!=1) { + cout << i << endl; + if(i%2==1) { + i = 3*i + 1; + } else { + i = i/2; + } + } +} -- GitLab