/*这个可以*/ /*真不易呀!(我没有帮你做图形界面的那样就得全改了没时间了*/
#include"stdio.h"
#include"conio.h"
#define Esc 27
#define Enter 13
#define upkey 72
#define downkey 80
#define Menu_x 35
#define Menu_y 12
void Fream()
{
textcolor(GREEN);
gotoxy(22,11);
cprintf("**********************************\n");
gotoxy(22,12);
cprintf("* *\n"); /*星号位子有变化自己动一下*/
gotoxy(22,13);
cprintf("* *\n");
gotoxy(22,14);
cprintf("* *\n");
gotoxy(22,15);
cprintf("**********************************\n");
}
void EnterFace(int choice)
{
int w,h,x,y;
x=Menu_x;
y=Menu_y;
textbackground(0);
clrscr();
Fream();
gotoxy(x,y);
if(choice==Menu_y)
textcolor(RED);
else
textcolor(WHITE);
cprintf("Enter");
gotoxy(x,y+2);
if(choice==Menu_y+2)
textcolor(RED);
else
textcolor(WHITE);
cprintf("Exit");
}
void main()
{
char key,password1[10],name1[10];
int i=0,old_x,old_y,choice,k=0;
struct user
{char *password;
char *name;
char *sex;
char *age;
};struct user User1;
User1.password="33467";
User1.name="yuewei";
old_x=Menu_x;
old_y=Menu_y;
choice=old_y;
EnterFace(old_y);
do
{
EnterFace(choice);
kbhit();
key=getch();
switch(key)
{
case upkey:
if(old_y==Menu_y)
choice=Menu_y+2;
else
choice=old_y-2;
old_y=choice;
EnterFace(choice);
break;
case downkey:
if(old_y==Menu_y+2)
choice=old_y-2;
else choice=old_y+2;
old_y=choice;
EnterFace(choice);
break;
case Enter:
switch(choice)
{case Menu_y:
for(i=0;i<3;i++)
{
Fream();
textcolor(WHITE);
gotoxy(old_x,old_y);
cprintf("User Name");
gotoxy(old_x,old_y+2);
while((name1[k]=getch())!='\r')
{ cprintf("*");
k++;}
name1[k]='\0';
k=0;
Fream();
textcolor(WHITE);
gotoxy(old_x,old_y);
cprintf("Password");
gotoxy(old_x,old_y+2);
while((password1[k]=getch())!='\r')
{
cprintf("*");
k++;}
password1[k]='\0';
if(strcmp(password1,User1.password)==0&&strcmp(name1,User1.name)==0)
{
Fream();
textcolor(WHITE);
gotoxy(old_x,old_y);
cprintf("Welcome");
gotoxy(old_x-10,old_y+2);
cprintf("press any key back");
getch();
break;
}
else
{
Fream();
textcolor(WHITE);
gotoxy(old_x,old_y);
cprintf("Error");
gotoxy(old_x-10,old_y+2);
cprintf("Password any key to continue.");
getch();
}
}
if(i==3)
{
Fream();
textcolor(WHITE);
gotoxy(old_x-10,old_y);
cprintf("Sorry,you do not can");
gotoxy(old_x,old_y+2);
cprintf("Bye,Bye");
sleep(3);
exit(0);
}
break;
case Menu_y+2:
exit(0);
break;
default:
break;
}
break;
default:
break;
}
}while(key!=Esc);
}
[[italic] 本帖最后由 xianshizhe111 于 2008-1-16 17:53 编辑 [/italic]]