Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. // starmania.c - Exercise 23
  2. // Date: 22-10-2019
  3. // Created by: Aiman El Aaqdi
  4.  
  5. #include <stdio.h>
  6. #pragma warning(disable:4996)
  7.  
  8. char CHAR_ASTERISK = '*';
  9.  
  10. void afficher_ligne(int x);
  11. void afficher_rectangle(int x, int y);
  12. void afficher_triangle(int y);
  13. void afficher_triangle_creux(int y);
  14. void afficher_triangle_miroir(int y);
  15. void PasserALaLigne();
  16.  
  17. int main() {
  18. int L, H;
  19.  
  20. printf("Give me the width number (used also to print the 'ligne'): ");
  21. scanf("%d", &L);
  22. printf("Give me the height number: ");
  23. scanf("%d", &H);
  24.  
  25. afficher_ligne(L);
  26. afficher_rectangle(L, H);
  27. afficher_triangle(L);
  28. afficher_triangle_miroir(L);
  29. afficher_triangle_creux(L);
  30.  
  31. return 0;
  32. }
  33.  
  34. void PasserALaLigne() {
  35. printf("\n");
  36. }
  37.  
  38. void afficher_ligne(int x) {
  39. for (int i = 0; i < x; i++) {
  40. printf("%c", CHAR_ASTERISK);
  41. }
  42.  
  43. PasserALaLigne();
  44. PasserALaLigne();
  45. }
  46.  
  47. void afficher_rectangle(int x, int y) {
  48. for (int i = 0; i < y; i++) {
  49. for (int j = 0; j < x; j++)
  50. printf("%c", CHAR_ASTERISK);
  51. PasserALaLigne();
  52. }
  53.  
  54. PasserALaLigne();
  55. PasserALaLigne();
  56. }
  57.  
  58. void afficher_triangle(int y) {
  59. for (int i = 1; i <= y; ++i)
  60. {
  61. for (int j = 1; j <= i; ++j)
  62. {
  63. printf("%c", CHAR_ASTERISK);
  64. }
  65. PasserALaLigne();
  66. }
  67.  
  68. PasserALaLigne();
  69. PasserALaLigne();
  70. }
  71.  
  72. void afficher_triangle_creux(int y) {
  73. for (int i = y - 1; i >= 0; i--)
  74. {
  75. for (int j = 0; j <= i; j++)
  76. {
  77. if (i == y - 1 || j == 0 || i == j)
  78. printf("%c", CHAR_ASTERISK);
  79. else
  80. printf(" ");
  81. }
  82. PasserALaLigne();
  83. }
  84. PasserALaLigne();
  85. PasserALaLigne();
  86. }
  87.  
  88. void afficher_triangle_miroir(int y) {
  89. for (int i = 1; i <= y; i++)
  90. {
  91. for (int j = i; j < y; j++)
  92. {
  93. printf(" ");
  94. }
  95.  
  96. for (int j = 1; j <= i; j++)
  97. {
  98. printf("%c", CHAR_ASTERISK);
  99. }
  100.  
  101. PasserALaLigne();
  102. }
  103. PasserALaLigne();
  104. PasserALaLigne();
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement