#include #include void tracetriangle( int xOrg, int yOrg, int nHauteur, char cMotif, int fBaseEstEnBas ) { int nBase = (2 * nHauteur ) - 1; int nToDisplay = nBase; if( fBaseEstEnBas ) { nToDisplay = 1; } for( int yLig = 0; yLig < nHauteur; yLig ++ ) { int nFirst = (nBase/2) - (nToDisplay/2); int nLast = (nBase/2) + (nToDisplay/2); for( int xCol = nFirst; xCol <= nLast; xCol ++ ) { gotoxy( xOrg + xCol, yOrg + yLig ); putchar( cMotif ); } if( fBaseEstEnBas ) { nToDisplay += 2; } else { nToDisplay -= 2; } } } void main() { window(1,1,80,25); clrscr(); tracetriangle( 1, 1, 10, '*', 1 ); tracetriangle( 1, 11, 10, '*', 0 ); getch(); }