summaryrefslogtreecommitdiff
path: root/codingbattle/exo1.cpp
diff options
context:
space:
mode:
authorGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
committerGaspard Coulet <gaspard.coulet@mines-ales.org>2021-04-28 23:05:53 +0200
commit9fe033ea88c2f705ec18c232873d056e0c229d72 (patch)
tree0647dc8c51610c7336c88c04de2068ea14b21e17 /codingbattle/exo1.cpp
Initial commit
Diffstat (limited to 'codingbattle/exo1.cpp')
-rw-r--r--codingbattle/exo1.cpp30
1 files changed, 30 insertions, 0 deletions
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<iostream>
+
+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 !")<<std::endl;
+ return 0;
+}