C语言如何实现返回主菜单?
1个回答
展开全部
如何再返回到主菜单 ?
下面我写的这个模板你参考下:
void dispMenu()
{
printf("===========菜单================\n");
printf("==1 功能1==============\n");
printf("==2 功能2==============\n");
printf("==0 退出==============\n");
}
void dispMenu1()
{
printf("===========菜单1================\n");
printf("==1 功能11==============\n");
printf("==2 功能12==============\n");
printf("==0 返回上层菜单==============\n");
}
void func1()
{
int cmd;
dispMenu1();
scanf("%d",&cmd);
while(cmd != 0)
{
if(cmd ==1)
func1();
}
}
void main()
{
int cmd;
dispMenu();
scanf("%d",&cmd);
while(cmd != 0)
{
if(cmd ==1)
func1();
dispMenu();
scanf("%d",&cmd);
}
}
下面我写的这个模板你参考下:
void dispMenu()
{
printf("===========菜单================\n");
printf("==1 功能1==============\n");
printf("==2 功能2==============\n");
printf("==0 退出==============\n");
}
void dispMenu1()
{
printf("===========菜单1================\n");
printf("==1 功能11==============\n");
printf("==2 功能12==============\n");
printf("==0 返回上层菜单==============\n");
}
void func1()
{
int cmd;
dispMenu1();
scanf("%d",&cmd);
while(cmd != 0)
{
if(cmd ==1)
func1();
}
}
void main()
{
int cmd;
dispMenu();
scanf("%d",&cmd);
while(cmd != 0)
{
if(cmd ==1)
func1();
dispMenu();
scanf("%d",&cmd);
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询