Advertisement
marwanpro

tp2 -- part frise

Sep 19th, 2016
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. #include <time.h>
  5. #include <stdlib.h>
  6. #define SPACE " "
  7.  
  8. using namespace std;
  9.  
  10. // Init Void
  11. void afficherFrise(int n, int l, int h);
  12. void top(int n, int l);
  13. void mid(int n, int l, int h);
  14. void bot(int n, int l);
  15.  
  16. int main(void)
  17. {
  18.     afficherFrise(5, 6, 7);
  19.     system("pause");
  20.     return 0;
  21. }
  22.  
  23.  
  24. void afficherFrise(int n, int l, int h)
  25. {
  26.     top(n, l);
  27.     mid(n, l, h);
  28.     bot(n, l);
  29. }
  30.  
  31. void top(int n, int l)
  32. {
  33.     for (int i = 0; i < n; i++)
  34.     {
  35.         for (int j = 0; j < l; j++)
  36.         {
  37.             cout << '*';
  38.         }
  39.         for (int j = 0; j < l-2; j++)
  40.         {
  41.             cout << SPACE;
  42.         }
  43.     }
  44.     cout << endl;
  45. }
  46.  
  47. void mid(int n, int l, int h)
  48. {
  49.     for (int i = 0; i < h; i++)
  50.     {
  51.         for (int j = 0; j < 2*n; j++)
  52.         {
  53.             cout << '*';
  54.             for (int k = 0; k < (l - 2); k++)
  55.             {
  56.                 cout << SPACE;
  57.             }
  58.         }
  59.         cout << endl;
  60.     }
  61. }
  62.  
  63. void bot(int n, int l)
  64. {
  65.     cout << '*';
  66.     for (int i = 0; i < n; i++)
  67.     {
  68.         for (int j = 0; j < l - 2; j++)
  69.         {
  70.             cout << SPACE;
  71.         }
  72.         for (int j = 0; j < l; j++)
  73.         {
  74.             cout << '*';
  75.         }
  76.     }
  77.     cout << endl;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement