un petit bout de code qui fait des triangles : #include <iostream.h> #include <windows.h> #define NBR 20 void main( ) { HANDLE hConsole; CONSOLE_SCREEN_BUFFER_INFO infoConsole; hConsole = GetStdHandle( STD_OUTPUT_HANDLE ); if(! GetConsoleScreenBufferInfo( hConsole, &infoConsole ) ) cout << "Erreur GetConsoleScreenBufferInfo"; COORD coCenter = { infoConsole.srWindow.Right / 2, 5 }; SetConsoleCursorPosition( hConsole, coCenter ); int i = 1; char etoile[NBR*2 + 1] = {'*'}; memset( etoile, '*', sizeof( etoile ) ); ULONG nbrEcrit = 0; do { for( int j = 0; j < i; j++ ) WriteConsoleOutputCharacter( hConsole, etoile, i + j, coCenter, &nbrEcrit ); coCenter.Y += 1; coCenter.X -= 1; } while( ++i <= NBR + 1 ); cout << endl; }
|