summaryrefslogtreecommitdiff
path: root/sem_2/HLIN202/TP/TP3-4/ex9/exo9.cpp
blob: 4d038cedd603f602f4f57c724e6231008330999b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>

void arbre ( int base) {
  if (base%2==1) {
    int espaces = (base-1)/2;
    int nb=1;
    int etage = base / 2 +1;
    for ( int i=1; i<=etage; i ++) {
      for ( int j=1; j<=espaces; j ++) {
        std::cout<<" ";
      }

        for (int k=1; k<=nb; k ++) {
        std::cout<<"*";
      }
      std::cout<<std::endl;
      espaces--;
      nb += 2;
    }
  }
}

int main () {
  int n=0;
  std::cout << " Entrez le nombre d'etoiles voulues a la base"<<std::endl;
  std::cin>>n;
  arbre(n);
  return 0;
}