Advertisement
marwanpro

tp2 -- part carre

Sep 19th, 2016
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 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 lignePleine(int n, char c);
  12. void ligneCreuse(int n, char c);
  13. void afficheCarre(int n, char c);
  14.  
  15. int main(void)
  16. {
  17.     afficheCarre(10, 'x');
  18.     system("pause");
  19.     return 0;
  20.  
  21. }
  22.  
  23. void lignePleine(int n, char c)
  24. {
  25.     for (int i = 0; i < n; i++)
  26.     {
  27.         cout << c;
  28.     }
  29.     cout << endl;
  30. }
  31.  
  32. void ligneCreuse(int n, char c)
  33. {
  34.     cout << c;
  35.     for (int i = 0; i < n - 2; i++)
  36.     {
  37.         cout << SPACE;
  38.     }
  39.     cout << c << endl;
  40. }
  41.  
  42. void afficheCarre(int n, char c)
  43. {
  44.     lignePleine(n, c);
  45.     for (int i = 0; i < n - 2; i++)
  46.     {
  47.         ligneCreuse(n, c);
  48.     }
  49.     lignePleine(n, c);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement