diff --git a/main.c b/main.c index 3d777cc..49b1fd3 100644 --- a/main.c +++ b/main.c @@ -1,46 +1,48 @@ #include #include #include - + void Locate(int x,int y) { -HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE); -COORD C; -C.X=(SHORT)x; -C.Y=(SHORT)y; -SetConsoleCursorPosition(H,C); + HANDLE H=GetStdHandle(STD_OUTPUT_HANDLE); + COORD C; + C.X=(SHORT)x; + C.Y=(SHORT)y; + SetConsoleCursorPosition(H,C); } - + void Afficher(int curs) { -Locate(0,0); -printf("%c Oui\n",(curs==0)?'>':' '); -printf("%c Non\n",(curs==1)?'>':' '); + Locate(0,0); + printf("%c Oui\n",(curs==0)?'>':' '); + printf("%c Non\n",(curs==1)?'>':' '); } + int Choisir() { -int curs = 0; -int touche; -do -{ -Afficher(curs); -touche = _getch(); -if (touche==0xE0) // fleche : le code fleche renvoie 2 caracteres. -{ -touche = _getch(); -if (touche==0x50 && curs==0)  // fleche bas -curs = 1; -if (touche==0x48 && curs==1)  // fleche haut -curs = 0; + int curs = 0; + int touche; + do + { + Afficher(curs); + touche = _getch(); + if (touche==0xE0) // fleche : le code fleche renvoie 2 caracteres. + { + touche = _getch(); + if (touche==0x50 && curs==0) // fleche bas + curs = 1; + if (touche==0x48 && curs==1) // fleche haut + curs = 0; + } + } while (touche!=0x0D); // enter + return curs; } -return curs; -} - + int main() { -int choix; -choix = Choisir(); -Locate(0,3); -printf("Vous avez choisi : %s\n",(choix==0)?"Oui":"Non"); -return 0; + int choix; + choix = Choisir(); + Locate(0,3); + printf("Vous avez choisi : %s\n",(choix==0)?"Oui":"Non"); + return 0; } \ No newline at end of file