summaryrefslogtreecommitdiff
path: root/codingbattle/exo2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'codingbattle/exo2.cpp')
-rw-r--r--codingbattle/exo2.cpp39
1 files changed, 39 insertions, 0 deletions
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;
+}