summaryrefslogtreecommitdiff
path: root/sem_2/HLIN202/TP/TP3-4/ex7
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 /sem_2/HLIN202/TP/TP3-4/ex7
Initial commit
Diffstat (limited to 'sem_2/HLIN202/TP/TP3-4/ex7')
-rw-r--r--sem_2/HLIN202/TP/TP3-4/ex7/exo7bin0 -> 9285 bytes
-rw-r--r--sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp34
2 files changed, 34 insertions, 0 deletions
diff --git a/sem_2/HLIN202/TP/TP3-4/ex7/exo7 b/sem_2/HLIN202/TP/TP3-4/ex7/exo7
new file mode 100644
index 0000000..1f9f23c
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP3-4/ex7/exo7
Binary files differ
diff --git a/sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp b/sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp
new file mode 100644
index 0000000..b0d86be
--- /dev/null
+++ b/sem_2/HLIN202/TP/TP3-4/ex7/exo7.cpp
@@ -0,0 +1,34 @@
+#include<iostream>
+#include<math.h>
+
+bool nombreeligible ( int n) {
+ int som=0,cpt =1, act=0, puiss=0;
+ act = n;
+ while ( n > 10 ) {
+ n= n/10;
+ cpt ++;
+ }
+ for ( int i=cpt; i >= 0; i--) {
+ puiss = (int) pow(10,i);
+ som += (int)pow((act/puiss)%10,3);
+ }
+ return som==act ? true : false ;
+}
+
+bool tripleteligible ( int a, int b, int c) {
+ int n = a*100 + b*10 + c;
+ return n == pow(a,3) + pow (b,3) + pow(c,3);
+}
+
+void testeentier () {
+ for (int i = 2; i < 1000; i ++) {
+ if(nombreeligible(i)) {
+ std::cout << i << std::endl;
+ }
+ }
+}
+
+int main () {
+ testeentier();
+ return 0;
+}