#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<ctype.h>
void cau1a()
{
clrscr();
}
void cau1b()
{
clrscr();
getch()
}
void cau1c()
{
clrscr();
getch();
}
void cau1d()
{
clrscr();
getch();
}
void cau1e()
{
clrscr();
getch();
}
/*==============================================*/
void VeMuc(int c1,int c2,int d,char S[],int mau)
{
struct text_info m;
gettextinfo(&m);
window(c1,d,c2,d);
textattr(mau);
clrscr();
cprintf(" %s",S);
gotoxy(m.curx,m.cury);
textattr(m.attribute);
}
void KHMeNu(int ct,int dt,int w,char cn[][50],int scn,int mauthuong,int chonmau,int &chon)
{
int i;
char ch;
for(i=0;i<scn;i++)
VeMuc(ct,ct+w,dt+i,cn[i],mauthuong);
do{
VeMuc(ct,ct+w,dt+chon,cn[chon],chonmau);
ch=getch();
if(ch==0) ch=getch();
VeMuc(ct,ct+w,dt+chon,cn[chon],mauthuong);
switch(ch)
{
case 72:chon--;
if(chon<0) chon=scn-1;
break;
case 80:chon++;
if(chon==scn) chon=0;
break;
}
}while(ch!=13&&ch!=27);
if(ch==27) chon=scn-1;
}
//-------------------------------------------------------
void MeNu1()
{
int scn=2;
char cn[2][50]={"Xem chuong trinh","Thoat"};
int chon=0;
do{
clrscr();
KHMeNu(1,1,25,cn,scn,WHITE+10*GREEN,BLACK+10*BROWN,chon);
clrscr();
switch(chon)
{
case 0: window(1,1,80,25);
cau1a();
break;
}
}while(chon<scn-2);
}
//-------------------------------------------------
void MeNu2()
{
int scn=2;
char cn[2][50]={"Xem chuong trinh","Thoat"};
int chon=0;
do{
clrscr();
KHMeNu(1,1,25,cn,scn,WHITE+16*GREEN,BLACK+16*BROWN,chon);
clrscr();
switch(chon)
{
case 0: window(1,1,80,25);
cau1b();
break;
}
}while(chon<scn-2);
}
//-------------------------------------------------
void MeNu3()
{
int scn=2;
char cn[2][50]={"Xem huong trinh","Thoat"};
int chon=0;
do{
clrscr();
KHMeNu(1,1,25,cn,scn,WHITE+16*GREEN,BLACK+16*BROWN,chon);
clrscr();
switch(chon)
{
case 0: window(1,1,80,25);
cau1c();
break;
}
}while(chon<scn-2);
}
//-------------------------------------------------
void MeNu4()
{
int scn=2;
char cn[2][50]={"Xem chuong trinh","Thoat"};
int chon=0;
do{
clrscr();
KHMeNu(1,1,25,cn,scn,WHITE+16*GREEN,BLACK+16*BROWN,chon);
clrscr();
switch(chon)
{
case 0: window(1,1,80,25);
cau1d();
break;
}
}while(chon<scn-2);
}
//-------------------------------------------------
void MeNu5()
{
int scn=2;
char cn[2][50]={"Xem chuong trinh","Thoat"};
int chon=0;
do{
clrscr();
KHMeNu(1,1,25,cn,scn,WHITE+16*GREEN,BLACK+16*BROWN,chon);
clrscr();
switch(chon)
{
case 0: window(1,1,80,25);
cau1e();
break;
}
}while(chon<scn-2);
}
//-------------------------------------------------
void MeNu()
{
int scn=6;
char cn[6][50]=
{
"[1] Cau 1a:",
"[2] Cau 1b:",
"[3] Cau 1c:",
"[4] Cau 1d:",
"[5] Cau 1e:",
"[-] Exit"
};
int chon=0;
do{clrscr();
//=======================
printf("\n=========== TOAN ROI RAC ============"); printf("\n= Sinh vien: Duong Cong Toan ="); printf("\n= MSSV: D06101222 ="); printf("\n= Lop: 07TH113 (Lop: 06CT3 HL) ="); printf("\n= GVHD: TRAN HANH ="); printf("\n====================================="); //======================
KHMeNu(1,15,25,cn,scn,WHITE+16*GREEN,BLACK+16*BROWN,chon);
clrscr();
switch(chon)
{
case 0: window(1,1,80,25);
clrscr();
MeNu1();
break;
case 1: window(1,1,80,25);
clrscr();
MeNu2();
break;
case 2: window(1,1,80,25);
clrscr();
MeNu3();
break;
case 3: window(1,1,80,25);
clrscr();
MeNu4();
break;
case 4: window(1,1,80,25);
clrscr();
MeNu5();
break;
case 5: window(1,1,80,25);
clrscr();
break;
}
}while(chon<scn-1);
}
void main()
{
MeNu();
window(1,1,80,25);
clrscr();
}