Advertisement
marwanpro

tp2 -- part 1

Sep 19th, 2016
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. #define SPACE " "
  5.  
  6. using namespace std;
  7.  
  8. // Init void
  9. int maximum(int a, int b);
  10. double factorielle(int n);
  11. void puiss2();
  12.  
  13. int main(void)
  14. {
  15.     double fact = factorielle(5);
  16.     cout << fact;
  17.     system("pause");
  18.     return 0;
  19. }
  20.  
  21. int maximum(int a, int b)
  22. {
  23.     if (a > b) return a;
  24.     return b;
  25. }
  26.  
  27. double factorielle(int n)
  28. {
  29.     int f = 1;
  30.     for (int i = 1; i < n + 1; i++)
  31.     {
  32.         f *= i;
  33.     }
  34.     return f;
  35. }
  36.  
  37. void puiss2()
  38. {
  39.     int somme = 0;
  40.     for (int i = 0; i < 3; i++)
  41.     {
  42.         somme += pow(2, i);
  43.         cout << somme;
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement