#include <stdio.h>
#include <Windows.h>
void gotoxy(int x,int y)
{
COORD xy={0,0};
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
xy.X=x;
xy.Y=y;
SetConsoleCursorPosition(hout,xy);
}
#define X 22
#define Y 6
void draw(void)
{
int i;
gotoxy(X,Y);
printf("┍");
for (i=0;i<20;i++)
{
printf("━");
}
printf("┑");
for (i=1;i<42;i++)
{
gotoxy(X,Y+i);
printf("│");
}
gotoxy(X,Y+i);
printf("┕");
for(i=0;i<20;i++)
{
printf("━");
}
for (i=1;i<42;i++)
{
gotoxy(X+42,Y+i);
printf("│");
}
gotoxy(X+42,Y+i);
printf("┙");
}
void drawmenu(void)
{
gotoxy(X+16,Y+18);
printf("1->选择菜单1");
gotoxy(X+16,Y+20);
printf(" 选择菜单2");
gotoxy(X+16,Y+22);
printf(" 选择菜单3");
gotoxy(0,0);
}
int selmenu_Num=0;
int selmenu(void)
{
int ch=0;
while(1)
{
scanf("%c",&ch);
if(ch==13)
{
return selmenu_Num;
}
switch (ch)
{
case 72:
selmenu_Num--;
if(selmenu_Num<0)
{
selmenu_Num=2;
}
break;
case 80:
if(selmenu_Num<2);
{
selmenu_Num=0;
}
break;
}
gotoxy(0,0);
switch(selmenu_Num)
{
case 0:
gotoxy(X+16,Y+18);
printf("1->");
gotoxy(X+16,Y+20);
printf(" ");
gotoxy(X+16,Y+22);
printf(" ");
gotoxy(0,0);
break;
case 1:
gotoxy(X+16,Y+18);
printf(" ");
gotoxy(X+16,Y+20);
printf("2->");
gotoxy(X+16,Y+22);
printf(" ");
gotoxy(0,0);
break;
case 2:
gotoxy(X+16,Y+18);
printf(" ");
gotoxy(X+16,Y+20);
printf(" ");
gotoxy(X+16,Y+22);
printf(" ");
gotoxy(0,0);
break;
}
}
return selmenu_Num;
}
void domenu(void)
{
int sel;
sel=selmenu();
switch(sel)
{
case 0:
gotoxy(0,0);
printf("\n菜单一功能\n");
break;
case 1:
gotoxy(0,0);
printf("\n菜单二功能\n");
break;
case 2:
exit(1);
break;
}
}
int main()
{
system("color 0B");
draw();
drawmenu();
domenu();
getchar();
getchar();
return 0;
}
#include <Windows.h>
void gotoxy(int x,int y)
{
COORD xy={0,0};
HANDLE hout=GetStdHandle(STD_OUTPUT_HANDLE);
xy.X=x;
xy.Y=y;
SetConsoleCursorPosition(hout,xy);
}
#define X 22
#define Y 6
void draw(void)
{
int i;
gotoxy(X,Y);
printf("┍");
for (i=0;i<20;i++)
{
printf("━");
}
printf("┑");
for (i=1;i<42;i++)
{
gotoxy(X,Y+i);
printf("│");
}
gotoxy(X,Y+i);
printf("┕");
for(i=0;i<20;i++)
{
printf("━");
}
for (i=1;i<42;i++)
{
gotoxy(X+42,Y+i);
printf("│");
}
gotoxy(X+42,Y+i);
printf("┙");
}
void drawmenu(void)
{
gotoxy(X+16,Y+18);
printf("1->选择菜单1");
gotoxy(X+16,Y+20);
printf(" 选择菜单2");
gotoxy(X+16,Y+22);
printf(" 选择菜单3");
gotoxy(0,0);
}
int selmenu_Num=0;
int selmenu(void)
{
int ch=0;
while(1)
{
scanf("%c",&ch);
if(ch==13)
{
return selmenu_Num;
}
switch (ch)
{
case 72:
selmenu_Num--;
if(selmenu_Num<0)
{
selmenu_Num=2;
}
break;
case 80:
if(selmenu_Num<2);
{
selmenu_Num=0;
}
break;
}
gotoxy(0,0);
switch(selmenu_Num)
{
case 0:
gotoxy(X+16,Y+18);
printf("1->");
gotoxy(X+16,Y+20);
printf(" ");
gotoxy(X+16,Y+22);
printf(" ");
gotoxy(0,0);
break;
case 1:
gotoxy(X+16,Y+18);
printf(" ");
gotoxy(X+16,Y+20);
printf("2->");
gotoxy(X+16,Y+22);
printf(" ");
gotoxy(0,0);
break;
case 2:
gotoxy(X+16,Y+18);
printf(" ");
gotoxy(X+16,Y+20);
printf(" ");
gotoxy(X+16,Y+22);
printf(" ");
gotoxy(0,0);
break;
}
}
return selmenu_Num;
}
void domenu(void)
{
int sel;
sel=selmenu();
switch(sel)
{
case 0:
gotoxy(0,0);
printf("\n菜单一功能\n");
break;
case 1:
gotoxy(0,0);
printf("\n菜单二功能\n");
break;
case 2:
exit(1);
break;
}
}
int main()
{
system("color 0B");
draw();
drawmenu();
domenu();
getchar();
getchar();
return 0;
}