Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // starmania.c - Exercise 23
- // Date: 22-10-2019
- // Created by: Aiman El Aaqdi
- #include <stdio.h>
- #pragma warning(disable:4996)
- char CHAR_ASTERISK = '*';
- void afficher_ligne(int x);
- void afficher_rectangle(int x, int y);
- void afficher_triangle(int y);
- void afficher_triangle_creux(int y);
- void afficher_triangle_miroir(int y);
- void PasserALaLigne();
- int main() {
- int L, H;
- printf("Give me the width number (used also to print the 'ligne'): ");
- scanf("%d", &L);
- printf("Give me the height number: ");
- scanf("%d", &H);
- afficher_ligne(L);
- afficher_rectangle(L, H);
- afficher_triangle(L);
- afficher_triangle_miroir(L);
- afficher_triangle_creux(L);
- return 0;
- }
- void PasserALaLigne() {
- printf("\n");
- }
- void afficher_ligne(int x) {
- for (int i = 0; i < x; i++) {
- printf("%c", CHAR_ASTERISK);
- }
- PasserALaLigne();
- PasserALaLigne();
- }
- void afficher_rectangle(int x, int y) {
- for (int i = 0; i < y; i++) {
- for (int j = 0; j < x; j++)
- printf("%c", CHAR_ASTERISK);
- PasserALaLigne();
- }
- PasserALaLigne();
- PasserALaLigne();
- }
- void afficher_triangle(int y) {
- for (int i = 1; i <= y; ++i)
- {
- for (int j = 1; j <= i; ++j)
- {
- printf("%c", CHAR_ASTERISK);
- }
- PasserALaLigne();
- }
- PasserALaLigne();
- PasserALaLigne();
- }
- void afficher_triangle_creux(int y) {
- for (int i = y - 1; i >= 0; i--)
- {
- for (int j = 0; j <= i; j++)
- {
- if (i == y - 1 || j == 0 || i == j)
- printf("%c", CHAR_ASTERISK);
- else
- printf(" ");
- }
- PasserALaLigne();
- }
- PasserALaLigne();
- PasserALaLigne();
- }
- void afficher_triangle_miroir(int y) {
- for (int i = 1; i <= y; i++)
- {
- for (int j = i; j < y; j++)
- {
- printf(" ");
- }
- for (int j = 1; j <= i; j++)
- {
- printf("%c", CHAR_ASTERISK);
- }
- PasserALaLigne();
- }
- PasserALaLigne();
- PasserALaLigne();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement