2025-03-31 13:38:35 +00:00

46 lines
783 B
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <windows.h>
#include <conio.h>
#include <stdio.h>
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);
}
void Afficher(int curs)
{
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;
}
return curs;
}
 
int main()
{
    int choix;
    choix = Choisir();
    Locate(0,3);
    printf("Vous avez choisi : %s\n",(choix==0)?"Oui":"Non");
    return 0;
}