```
#include <iostream>
#include <conio.h>
#include <Windows.h>
using namespace std;
void gotoxy(int i,int j)
{
COORD position={j,i};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
}
char key()
{
int c;
while(1)
{
c = getch();
if (c ==224)
{
c = getch();
}
switch (c)
{
case 72:return 'u'; break;
case 80:return 'd'; break;
case 115:return 'd'; break;
case 119:return 'u';break;
case 83:return 'd'; break;
case 87:return 'u'; break;
case 13:return 'O'; break;
}
}
}
void hidden()//Òþ²Ø¹â±ê
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut,&cci);
cci.bVisible=0;//¸³1ΪÏÔʾ£¬¸³0ΪÒþ²Ø
SetConsoleCursorInfo(hOut,&cci);
}
void unhidden()//ÏÔʾ¹â±ê
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO cci;
GetConsoleCursorInfo(hOut,&cci);
cci.bVisible=1;//¸³1ΪÏÔʾ£¬¸³0ΪÒþ²Ø
SetConsoleCursorInfo(hOut,&cci);
}
void color(char c)
{
if(c=='G') SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN);
else if(c=='R') SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
else if(c=='W') SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
else if(c=='B') SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE);
else if(c=='P') SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_RED);
}
int choosen(int n,string chose[],string problem)
{
hidden();
system("cls");
gotoxy(0,0);
cout<<problem<<endl;
int x=0,ans=1;
char cs;
for(int i=0;i<n;i++)cout<<" "<<chose[i];
while(1)
{
int x1=x;
gotoxy(x+2,0);
color('R');
cout<<" *"<<chose[x];
color('W');
cs=key();
if(cs=='d')
{
if(x!=n-1)x++;
else x=0;
}
else if(cs=='u')
{
if(x!=0) x--;
else x=n-1;
}
else if(cs=='O')
{
unhidden();
return x+1;
}
gotoxy(x1+2,0);
cout<<" ";
gotoxy(x1+2,0);
cout<<" "<<chose[x1]<<" ";
}
}
int main()
{
string Q[3]={"123123\n","123123\n","hello\n"};
cout<<choosen(3,Q,"Ñ¡Ôñ\n")<<endl;
return 0;
}
```