/* --------------------- RETURN THE SELECTED CHOICE -----------------------*/ int getChoice(void){ int ch,i; displaymenu(); highlightChoice1(choiceID); while(ch!=13){ ch=getch(); /* printf("%d",ch); */ switch(ch){ case ARROWUP : /* arrow up */ choiceID--; if (choiceID<1) { choiceID=3; } break; case ARROWDOWN : /* arrow down */ choiceID++; if (choiceID>3) { choiceID=1; } break; } displaymenu(); highlightChoice1(choiceID); } return choiceID; }
void main() { int gm,i,count, gd=DETECT,choice=1,width=0; char **buffer; initgraph(&gd,&gm,"c:\\tc\\bgi"); if(initmouse()==0) { printf("\nUnable to intialize Mouse......"); exit(); } count=sizeof(menu)/sizeof(char*); settextstyle(TRIPLEX_FONT,0,3); displaymenu(menu,count,100,100); for(i=0;i<count;i++) { if (textwidth(menu[i])>width) width=textwidth(menu[i]); } buffer=malloc(sizeof(menu)); savemenu(menu,buffer,width,count,100,100); while(choice!=6) { choice=getresponse(menu,buffer,width,count,100,100); gotoxy(50,15); printf("\n\n\nYou have selected %s",menu[choice-1]); } }
//主函数 main() { createheadlink();//建立链表表头 readinformationfile();// 从文件中读学生信息 setadministrator();// displaymenu();//显示菜单,根据用户输入完成相应的功能 }
int main(){ int com; srand(time(NULL)); do{ com = displaymenu(); switch(com){ case 1: addition(); break; case 2: subtraction(); break; case 3: multiplication(); break; case 4: division(); break; case 5: printf("Have a nice day\n"); } }while(com != 5); //needed for all basic programs to run for the professor system("pause"); return(0); }
int main() { //construct 2d array to store students'records int stu[4][5]={{1232,10,23,45,56},{2343,45,43,24,78},{2345,34,45,45,45},{3423,67,6,65,56}}; //show menu int yourchoice; char confirm; displaymenu(); do { printf("Enter your choice(1-3):"); scanf("%d",&yourchoice); switch(yourchoice){ case 1:viewall(stu);break; case 2:viewbyid(stu);break; case 3:showhl(stu);break; default:printf("invalid"); } printf("Press y or Y to continue:"); scanf("%s", &confirm); }while(confirm=='y'||confirm=='Y'); system("PAUSE"); return 0; }
void bill() { int df=0,o=0,t,j,c=0,a[100],q[100]; s=0; system("cls"); displaymenu(); printf("\n\n Enter the total no. of Items you want to purchase - "); scanf("%d",&t); for(j=1;j<=t;j++) { system("cls"); displaymenu(); i=j; c=0; pos(); printf("\n\n %d%c%c Item No. = ",j,x,y); scanf("%d",&a[j]); printf("\n\n Quantity = "); scanf("%d",&q[j]); fs=fopen("noe.txt","r"); fp=fopen("PROJECT.txt","r"); fscanf(fs,"%d",&n); for(i=1;i<=n;i++) { fread(&m1,sizeof(m1),1,fp); pos(); if(i==a[j]) { printf("\n\n Item Details -"); printf("\n ^^^^^^^^^^^^"); if(i<10) { printf("\n\n %d%c%c Item Name - %s",i,x,y,m1[i].itemname); printf("\n\n Price - %.2f",m1[i].itemprice); s+=m1[i].itemprice*q[j]; } else { printf("\n\n %d%c%c Item Name - %s",i,x,y,m1[i].itemname); printf("\n\n Price - %.2f",m1[i].itemprice); s+=m1[i].itemprice*q[j]; } c=1; df++; getch(); } } if(c==0) { printf("\n\n Item doesn't Exist in the Menu "); getch(); } } fclose(fs); fclose(fp); if(df!=0) { system("cls"); printf("\n ********************************* Cash Memo **********************************"); printf("\n ********************************* ^^^^ ^^^^ **********************************"); printf("\n================================================================================"); gotoxy(2,7); printf("Serial Number"); gotoxy(2,8); printf("^^^^^^ ^^^^^^"); gotoxy(20,7); printf("Item Name"); gotoxy(20,8); printf("^^^^ ^^^^"); gotoxy(42,7); printf("Quantity"); gotoxy(42,8); printf("^^^^^^^^"); gotoxy(60,7); printf("Price"); gotoxy(60,8); printf("^^^^^"); for(j=1;j<=t;j++) { fs=fopen("noe.txt","r"); fp=fopen("PROJECT.txt","r"); fscanf(fs,"%d",&n); for(i=1;i<=n;i++) { fread(&m1,sizeof(m1),1,fp); if(i==a[j]) { ++o; gotoxy(2,9+j); printf("%d",o); gotoxy(20,9+j); printf("%s",m1[i].itemname); gotoxy(45,9+j); printf("%d",q[j]); gotoxy(60,9+j); printf("%.2f",m1[i].itemprice*q[j]); } } } gotoxy(1,45); printf("==============================================================================="); gotoxy(50,46); printf(" Total Payment = %.2f",s); gotoxy(1,47); printf("==============================================================================="); getch(); system("cls"); fclose(fs); fclose(fp); }}
//////////////////////显示菜单,根据用户输入完成相应的功能 void displaymenu() { student *p; system("color 5e"); /* HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(handle, FOREGROUND_INTENSITY |FOREGROUND_RED | FOREGROUND_GREEN);*/ printf(" ********请选择相应的功能********\n"); printf(" 1 显示所有学生信息\n"); printf(" 2 按姓名查询学生信息\n"); printf(" 3 按学号查询学生信息\n"); printf(" 4 增加学生信息\n"); printf(" 5 删除学生信息\n"); printf(" 6 按姓名修改学生成绩\n"); printf(" 7 按学号修改学生成绩\n"); printf(" 8 保存所有学生信息\n"); printf(" 9 显示优秀和不及格学生成绩\n"); printf(" 10 排序结果并输出成绩\n"); printf(" 11 退出程序\n"); printf(" 12 修改密码\n"); scanf("%d",&choose);//用户选择 switch(choose) { case 1: outputinformation(); break; case 2: displayinformationbystudentname(); break; case 3: displayinformationbystudentnumber(); break; case 4: p=mallocnode(); getinformation(p); insertonenode(p); break; case 5: deletenodebystudentnumber(); break; case 6: changemarkbystudentname(); break; case 7: changemarkbystudentnumber(); break; case 8: savelinktofile(); break; case 9: displaymarksegment(); break; case 10: compositorbytotalmark(); break; case 11: savelinktofile(); free(headlink); return; case 12: changepassword(); break; default: break; } displaymenu();//递归调用 }
void menu() { int option; BSTAddr bstAddr = 0; BSTNodeAddr bstNodeAddr; bstAddr = (BSTAddr) malloc(sizeof(BSTAddr)); (*bstAddr) = 0; do { printf("\n**************************************" "\n* BST *" "\n* 1. Insert Fraction *" "\n* 2. Display *" "\n* 3. Search for Fraction *" "\n* 4. Remove a Node *" "\n* 5. Get and Display Smallest Node *" "\n* 6. Quit *" "\n**************************************"); printf("\nSelect the option (1 throuh 6): "); scanf("%d", &option); switch(option) { case 1: bstNodeAddr = createBSTNode(); insertFractionBSTYourName(bstAddr, bstNodeAddr); break; case 2: if (*bstAddr == 0) { printf("\nThere are no fractions to display\n"); } else { displaymenu(*bstAddr); } break; case 3: if (*bstAddr == 0) { printf("\nThere are no fractions to search for\n"); } else { searchFractionBSTYourName(*bstAddr); } break; case 4: if (*bstAddr == 0) { printf("\nThere are no fractions to remove\n"); } else { removeFractionBSTYourname(bstAddr); } break; case 5: if (*bstAddr == 0) { printf("\nThere are no fractions to get\n"); } else { getSmallestFractionBSTYourName(*bstAddr); } break; case 6: printf("\n Have Fun!\n\n"); free(bstAddr); break; default: printf("\n You should not be in this class!\n\n"); } } while (option != 6); return; }
main() { displaymenu(); }