c语言实现菜单功能,C语言用if语句实现菜单功能

1,C语言用if语句实现菜单功能switch语句 不懂百度下这样能学到东西我也懒得打字#includemain() { int n=0; printf("*************************************\n"); printf("* 1---成绩输入 *\n"); printf("* 2---成绩插入 *\n"); printf("* 3---成绩查询 *\n"); printf("* 4---成绩排序 *\n"); printf("* 5---成绩删除 *\n"); printf("* 6---成绩输出 *\n"); printf("* 0---退出 *\n"); printf("*************************************\n"); printf("请输入你的选择(0---6)"); scanf("%d",&n); switch(n) { case 1: printf("成绩输入\n"); /*此处添加相应的功能*/ break; case 2: printf("成绩插入\n"); /*此处添加相应的功能*/ break; case 3: printf("成绩查询\n"); /*此处添加相应的功能*/ break; case 4: printf("成绩排序"); /*此处添加相应的功能*/ break; case 5: printf("成绩删除\n"); /*此处添加相应的功能*/ break; case 6: printf("成绩输出\n"); /*此处添加相应的功能*/ break; case 0: break; default: printf("error:command not found"); break; } }
2 , 如何用c语言实现文本菜单界面这样的可以吗?这都是使用printf打印出来的,之后等待用户输入一个数值,根据这个数值调用不同的功能函数,即可实现文字菜单效果1234567891011121314151617181920212223242526272829 /************************************************* 函数名:Menu* 功能:绘制主菜单界面,并根据输入转跳到其它功能************************************************/intMenu() charcScan;//cScan用于记录键盘的输入 /* ┏━┓┃┛┗ */ printf("\n\n"); printf("\t┏━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"); printf("\t┃ 欢迎使用员工管理系统BetaV1.0 ┃\n"); printf("\t┃ by 1500830221 ┃\n"); printf("\t┃ 1、查看所有员工信息 ┃\n"); printf("\t┃ 2、添加员工 ┃\n"); printf("\t┃ 3、查找员工 ┃\n"); printf("\t┃ 4、删除员工或修改资料 ┃\n"); printf("\t┃ 5、重设密码 ┃\n"); printf("\t┃ 6、将员工信息以文本文档输出 ┃\n"); printf("\t┃ 7、清屏 ┃\n"); printf("\t┃ 8、查看版本信息 ┃\n"); printf("\t┃ 9、退出 ┃\n"); printf("\t┃ ┃\n"); printf("\t┗━━━━━━━━━━━━━━━━━━━━━━━━━┛\n\n"); cScan=getch(); returncScan-48;}
3,求一个C语言菜单程序简单的就行会的重赏begin:printf("\t******************\n");printf("\t1--------------排序\n");printf("\t2--------------查询\n");printf("\t3--------------插入\n");printf("\t4--------------删除\n");printf("\t5--------------退出\n");printf("\t******************\n");a=getche();printf("\n");switch(a){case 49: paixu();goto begin;case 50: chaxun();goto begin;case 51: charu();goto begin;case 52: shanchu();goto begin;case 53: return;default:printf("\n\t选择错误,请重新选择");getch();goto begin;}参考一下吧?。。?#include#include #include void main() { char str; int i,k,choice=1; int gd=DETECT,gm; initgraph(&gd,&gm," "); setbkcolor(2); settextstyle(3,0,3); outtextxy(140,120,"A. The Mock Clock."); outtextxy(140,150,"B. The Digital Clock."); outtextxy(140,180,"C. Exit."); setlinestyle(0,0,3); rectangle(170,115,370,145); /*按上下键选择所需选项*/ for(i=1;i<=100;i++) { str=getch(); if(str==72) { --choice; if(choice==0)choice=3; } if(str==80) { ++choice; if(choice==4)choice=1; } if(str==13)break; /*画图做菜单*/ cleardevice(); switch(choice) { case 1: setlinestyle(0,0,3); rectangle(170,115,400,145); settextstyle(3,0,3); outtextxy(140,120,"A. The Mock Clock."); settextstyle(3,0,3); outtextxy(140,150,"B. The Digital Clock."); outtextxy(140,180,"C. Exit."); break; case 2: setlinestyle(0,0,3); rectangle(170,145,400,175); settextstyle(3,0,3); outtextxy(140,120,"A. The Mock Clock."); settextstyle(3,0,3); outtextxy(140,150,"B. The Digital Clock."); settextstyle(3,0,3); outtextxy(140,180,"C. Exit."); break; case 3: settextstyle(3,0,3); outtextxy(140,120,"A. The Mock Clock."); outtextxy(140,150,"B. The Digital Clock."); settextstyle(3,0,3); outtextxy(140,180,"C. Exit."); setlinestyle(0,0,3); rectangle(170,175,400,205); break; } } if(i>=100)exit(0); switch(choice)/*这里引用函数,实现所要的功能*/ { case 1: cleardevice(); setbkcolor(4); settextstyle(3,0,4); outtextxy(160,120,"No.1 have not built."); break; case 2: cleardevice(); setbkcolor(4); settextstyle(3,0,4); outtextxy(160,150,"No.2 have not built."); break; case 3: exit(0); } getch(); closegraph(); }【c语言实现菜单功能,C语言用if语句实现菜单功能】

    推荐阅读