怎么用C语言编写菜单?

怎么用C语言编写调用各章节作业答案的菜单???

第1个回答  2013-09-13
#include "stdio.h"
#include "stdlib.h"
#include "dos.h"
#include "windows.h"
char choice1;
void main()
{
void menue1();
printf("欢迎进入Ben的作业查询系统!");
menue1();
}
void menue1()
{
void choicemenue1();
printf("\n请按照以下列表选择您想要查看的章节:");
printf("\n编号\t章节\n 1\t第一章\n 2\t第二章\n");
printf("请输入编号进行选择:");
choicemenue1();
}
void choicemenue1()
{
choice1=getch();
switch(choice1)
{
void menuechapter1();
void menuechapter2();
void menue1();
case '1':menuechapter1();break;
case '2':menuechapter2();break;
default:printf("\n输入错误!请重新选择!\n"),menue1();
}}
void menuechapter1()
{
char choiceex;
printf("\n您选择的是第%c章",choice1);
printf("\n现在请选择本章节的题目。");
printf("\n请按照以下列表选择题目:");
printf("\n编号\t题目编号\n1\t第1题\n2\t第2题\n");
printf("请选择:");
switch(choiceex=getch())
{
void c1_1();
void c1_2();
case '1':c1_1();break;
case '2':c1_2();break;
default:
printf("\n你个白痴!这也能选错!不让你重选了!");
printf("\n按任意键以退出!");
getch();
exit(0);
}
}
void menuechapter2()
{
char choiceex;
printf("\n您选择的是第%c章",choice1);
printf("\n现在请选择本章节的题目。");
printf("\n请按照以下列表选择题目:");
printf("\n编号\t题目编号\n1\t第1题\n2\t第2题\n");
printf("\n请选择:");
switch(choiceex=getch())
{
void c2_1();
void c2_2();
case '1':c2_1();break;
case '2':c2_2();break;
default:
printf("\n你个白痴!这也能选错!不让你重选了!");
printf("\n按任意键以退出!");
getch();
exit(0);
}
}
void c1_1()
{
char howtorun;
printf("现在请选择考察方式:");
printf("\n编号\t考察方式\n 1\t运行程序\n 2\t查看源代码\n 3\t返回主菜单\n 4\t退出程序\n");
printf("请选择:");
switch(howtorun=getch())
{
void runc1_1();
void menue1();
case '1':runc1_1();break;
case '2':printf("\n"),system("type \\caidan\\chapter1\\c1_1.c"),printf("\n"),getch();break;
case '3':menue1();break;
case '4':exit(0);break;
default:
printf("程序即将结束!哈哈哈……");
printf("按任意键以结束程序!");
getch();
exit(0);
}}
void c1_2()
{
printf("c1_2 is OK!");
}void c2_1()
{
printf("c2_1 is OK!");
}void c2_2()
{
printf("c2_2 is OK!");
}
void runc1_1()
{
int a,b,max;
printf("\nPlease input two integer numbers:");
printf("a=?,b=?\n");
scanf("%d,%d",&a,&b);
max=a>b?a:b;
printf("The max number is %d",max);
}
大概就是这样做的。。本回答被网友采纳
第2个回答  2013-09-13
printf( "\n"
"\t1.第一章\n"
"\t2.第二章\n"
"\t3.第三章\n"
"\n" );接着就用switch( ch )来调用各个章节.比如.switch( ch )
{
case 1 : //调用第一章答案
break;

case 2 : //调用第二章答案
break;

case 3 : //调用第三章答案
break;
}
相似回答