First commit
This commit is contained in:
64
IUT/Info1/TD/Exercices/9.7_dessin_motifs/dessin.cpp
Normal file
64
IUT/Info1/TD/Exercices/9.7_dessin_motifs/dessin.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "dessin.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
void afficher_n_caractere(
|
||||
unsigned int nombre_etoiles,
|
||||
char caractere
|
||||
) {
|
||||
for (
|
||||
unsigned int i = 0;
|
||||
i < nombre_etoiles;
|
||||
i++
|
||||
) {
|
||||
cout << caractere;
|
||||
}
|
||||
}
|
||||
|
||||
void triangle_croissant(
|
||||
unsigned int taille
|
||||
) {
|
||||
for (
|
||||
unsigned int i = 1;
|
||||
i <= taille;
|
||||
i++
|
||||
) {
|
||||
afficher_n_caractere(i, '*');
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void triangle_decroissant(
|
||||
unsigned int taille
|
||||
) {
|
||||
for (
|
||||
unsigned int i = taille;
|
||||
i >= 1;
|
||||
i--
|
||||
) {
|
||||
afficher_n_caractere(i, '*');
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void sapin(
|
||||
unsigned int taille
|
||||
) {
|
||||
unsigned int nombre_espaces;
|
||||
unsigned int nombre_etoiles = 1;
|
||||
unsigned int nombre_espaces_tronc = taille - 1;
|
||||
|
||||
for (unsigned int i = 0; i < taille; i++) {
|
||||
nombre_espaces = taille - i;
|
||||
|
||||
afficher_n_caractere(nombre_espaces, ' ');
|
||||
afficher_n_caractere(nombre_etoiles, '*');
|
||||
cout << endl;
|
||||
|
||||
nombre_etoiles += 2;
|
||||
}
|
||||
afficher_n_caractere(nombre_espaces_tronc, ' ');
|
||||
cout << "|_|" << endl;
|
||||
}
|
||||
Reference in New Issue
Block a user