First commit
This commit is contained in:
24
IUT/Info1/TD/Exercices/9.7_dessin_motifs/.txt
Normal file
24
IUT/Info1/TD/Exercices/9.7_dessin_motifs/.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
*
|
||||
***
|
||||
*****
|
||||
*******
|
||||
*********
|
||||
|_|
|
||||
|
||||
|
||||
*
|
||||
***
|
||||
*****
|
||||
*******
|
||||
*********
|
||||
***********
|
||||
|_|
|
||||
|
||||
*
|
||||
***
|
||||
|_|
|
||||
|
||||
*
|
||||
|_|
|
||||
|
||||
|_|
|
||||
BIN
IUT/Info1/TD/Exercices/9.7_dessin_motifs/9.7
Normal file
BIN
IUT/Info1/TD/Exercices/9.7_dessin_motifs/9.7
Normal file
Binary file not shown.
BIN
IUT/Info1/TD/Exercices/9.7_dessin_motifs/dessin
Normal file
BIN
IUT/Info1/TD/Exercices/9.7_dessin_motifs/dessin
Normal file
Binary file not shown.
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;
|
||||
}
|
||||
15
IUT/Info1/TD/Exercices/9.7_dessin_motifs/dessin.h
Normal file
15
IUT/Info1/TD/Exercices/9.7_dessin_motifs/dessin.h
Normal file
@@ -0,0 +1,15 @@
|
||||
void triangle_croissant(
|
||||
unsigned int taille
|
||||
);
|
||||
|
||||
void triangle_decroissant(
|
||||
unsigned int taille
|
||||
);
|
||||
|
||||
void sapin(
|
||||
unsigned int taille
|
||||
);
|
||||
|
||||
void afficher_n_caractere(
|
||||
unsigned int nombre_etoiles
|
||||
);
|
||||
BIN
IUT/Info1/TD/Exercices/9.7_dessin_motifs/main
Normal file
BIN
IUT/Info1/TD/Exercices/9.7_dessin_motifs/main
Normal file
Binary file not shown.
21
IUT/Info1/TD/Exercices/9.7_dessin_motifs/main.cpp
Normal file
21
IUT/Info1/TD/Exercices/9.7_dessin_motifs/main.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "dessin.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
unsigned int taille;
|
||||
|
||||
cout << "Saisir la taille des triangle" << endl;
|
||||
cin >> taille;
|
||||
|
||||
|
||||
triangle_croissant(taille);
|
||||
cout << endl;
|
||||
triangle_decroissant(taille);
|
||||
cout << endl;
|
||||
sapin(taille);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user