summaryrefslogtreecommitdiff
path: root/codingbattle
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
Initial commit
Diffstat (limited to 'codingbattle')
-rw-r--r--codingbattle/exo1.cpp30
-rw-r--r--codingbattle/exo2.cpp39
-rw-r--r--codingbattle/sujets.7zbin0 -> 2186783 bytes
3 files changed, 69 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;
+}
diff --git a/codingbattle/exo2.cpp b/codingbattle/exo2.cpp
new file mode 100644
index 0000000..20af586
--- /dev/null
+++ b/codingbattle/exo2.cpp
@@ -0,0 +1,39 @@
+#include<iostream>
+
+int main ( int agrc, char ** argv) {
+ int note, mini, maxi;
+ float moy;
+ int n;
+ std::cin>>note;
+ std::cin>>mini>>maxi;
+ std::cin>>moy;
+ std::cin>>n;
+ int tab[n];
+ for (int i =0; i < n; i ++) {
+ std::cin>>tab[i];
+ }
+ int tmp;
+ int somme=0;
+ for (int j =0; j < n -1; j ++){
+ for (int i = j; i < n-1; i ++) {
+ if ( tab[i]> tab[i+1]){
+ tmp = tab[i+1];
+ tab[i+1] = tab[i];
+ tab[i] = tmp;
+ }
+ }
+}
+ for ( int i =0; i < n-1; i ++) {
+ somme+=tab[i];
+ }
+ somme+=tab[n-1];
+ somme+=note;
+ float moy2 = (float)somme/(float)(n+1);
+ if ( maxi != tab[n-1] || mini!=tab[0] || moy2 > moy + 0.02 || moy2 < moy - 0.02) {
+ std::cout<<"Jack ! Viens ici !"<<std::endl;
+ }
+ else {
+ std::cout<<"RAS"<<std::endl;
+ }
+ return 0;
+}
diff --git a/codingbattle/sujets.7z b/codingbattle/sujets.7z
new file mode 100644
index 0000000..637baf8
--- /dev/null
+++ b/codingbattle/sujets.7z
Binary files differ