From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- codingbattle/exo1.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 codingbattle/exo1.cpp (limited to 'codingbattle/exo1.cpp') diff --git a/codingbattle/exo1.cpp b/codingbattle/exo1.cpp new file mode 100644 index 0000000..26f33c9 --- /dev/null +++ b/codingbattle/exo1.cpp @@ -0,0 +1,30 @@ +#include + +int main ( int agrc, char ** argv) { + int fet; + int tmp; + int nb_courses; + std::cin >> fet; + std::cin>>nb_courses; + int tab[nb_courses]; + for(int i =0; i < nb_courses; i ++) { + std::cin >> tab[i]; + } + + for (int i = 0; i < nb_courses-1; i ++) { + if ( tab[i]> tab[i+1]){ + tmp = tab[i+1]; + tab[i+1] = tab[i]; + tab[i] = tmp; + } + } + int med; + if (nb_courses%2==0) { + med = (tab[nb_courses/2] + tab[nb_courses/2+1])/2; + } + else { + med = tab[(nb_courses/2)+1]; + } + std::cout<< ((med < fet) ? "Parie !" : "Jockey suivant !")<