l543664486
2020-02-22 17:08
采纳率: 100%
浏览 907

利用c语言制作二级菜单,一直报错,很无奈

#include
#include
void nemu1();
void nemu2();
int main()
{ int x;
while(1);
{system("cls");
printf("\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\t1:顺序表\n");
printf("\t\t\t\t\t2:链表\n");
printf("\t\t\t\t\t3:退出\n");
printf("\n\t\t\t\t\t请输入您的选择(1-3)=:");
scanf("%d",&x);
}
switch(x)
{case 1:nemu1(); break;
case 2:nemu2(); break;
default:printf("error"); break;}
return 1;
}

void menu1();
{int y;
while(1)
{system("cls");
printf("\n\n\n\n\n\n\n\n");

printf("\t\t\t\t\t1:创建顺序线性表\n");
printf("\t\t\t\t\t2:求顺序线性表的长度\n");
printf("\t\t\t\t\t3:按序号取顺序表元素\n");
printf("\t\t\t\t\t4:按值查找顺序表\n");
printf("\t\t\t\t\t5:插入元素\n");
printf("\t\t\t\t\t6:删除元素\n");
printf("\t\t\t\t\t7:输出顺序线性表\n");
printf("\t\t\t\t\t8:返回\n");
printf("\t\t\t\t\t\t请输入您的选择(1-8)=:");
scanf("%d",&y);}
if(y==8) break;
switch(y)
{ case 1:printf("这里是创建顺序线性表"); break;
case 2:printf("这里是求顺序线性表的长度");break;
case 3:printf("这里是按序号取顺序表元素"); break;
case 4:printf("这里是按值查找顺序表"); break;
case 5:printf("这里是插入元素"); break;
case 6:printf("这里是删除元素"); break;
case 7:printf("这里是输出顺序线性表"): break;
default:printf("error"); break;}
return 1;
}

void menu2();
{int z;
while(1)
{system("cls");
printf("\n\n\n\n\n\n\n\n");
printf("\t\t\t\t\t1:创建链式线性表\n");
printf("\t\t\t\t\t2:求链式线性表的长度\n");
printf("\t\t\t\t\t3:按序号取链表元素\n");
printf("\t\t\t\t\t4:按序号取链表元素\n");
printf("\t\t\t\t\t5:插入元素\n");
printf("\t\t\t\t\t6:删除元素\n");
printf("\t\t\t\t\t7:输出链式线性表\n");
printf("\t\t\t\t\t8:返回\n");
printf("\t\t\t\t\t\t请输入您的选择(1-8)=:");
scanf("%d",&z);}
if(z==8) break;
switch(x)
{ case 1:printf("这里是创建链式线性表"); break;
case 2:printf("这里是求链式线性表的长度"); break;
case 3:printf("这里是按序号取链表元素"); break;
case 4:printf("这里是按序号取链表元素"); break;
case 5:printf("这里是插入元素"); break;
case 6:printf("这里是删除元素"); break;
case 7:printf("这里是输出链式线性表");break;
default:printf("error"); break;}
return 1;
}

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • EricNTH.CN 2020-02-22 17:59
    已采纳
    #include <bits/stdc++.h>
    int menu1();
    int menu2();
    int main() {
        int x;
        while(1) {
            system("cls");
            printf("\n\n\n\n\n\n\n\n");
            printf("\t\t\t\t\t1:顺序表\n");
            printf("\t\t\t\t\t2:链表\n");
            printf("\t\t\t\t\t3:退出\n");
            printf("\n\t\t\t\t\t请输入您的选择(1-3)=:");
            scanf("%d",&x);
            switch(x)
            {
                case 1:menu1(); break;
                case 2:menu2(); break;
                case 3:return 0;break;
                default:printf("error");return 1; break;
            }
            printf("\n");
            system("pause");
        }
        return 0;
    }
    
    int menu1() {
        int y;
        while(1) {
            system("cls");
            printf("\n\n\n\n\n\n\n\n");
    
            printf("\t\t\t\t\t1:创建顺序线性表\n");
            printf("\t\t\t\t\t2:求顺序线性表的长度\n");
            printf("\t\t\t\t\t3:按序号取顺序表元素\n");
            printf("\t\t\t\t\t4:按值查找顺序表\n");
            printf("\t\t\t\t\t5:插入元素\n");
            printf("\t\t\t\t\t6:删除元素\n");
            printf("\t\t\t\t\t7:输出顺序线性表\n");
            printf("\t\t\t\t\t8:返回\n");
            printf("\t\t\t\t\t\t请输入您的选择(1-8)=:");
            scanf("%d",&y);
            if(y==8) break;
            switch(y) { 
                case 1:printf("这里是创建顺序线性表"); break;
                case 2:printf("这里是求顺序线性表的长度");break;
                case 3:printf("这里是按序号取顺序表元素"); break;
                case 4:printf("这里是按值查找顺序表"); break;
                case 5:printf("这里是插入元素"); break;
                case 6:printf("这里是删除元素"); break;
                case 7:printf("这里是输出顺序线性表"); break;
                default:printf("error"); break;
            }
            printf("\n");
            system("pause");
        }
        return 1;
    }
    
    int menu2(){
    int z;
    while(1)
    {
    system("cls");
    printf("\n\n\n\n\n\n\n\n");
    printf("\t\t\t\t\t1:创建链式线性表\n");
    printf("\t\t\t\t\t2:求链式线性表的长度\n");
    printf("\t\t\t\t\t3:按序号取链表元素\n");
    printf("\t\t\t\t\t4:按序号取链表元素\n");
    printf("\t\t\t\t\t5:插入元素\n");
    printf("\t\t\t\t\t6:删除元素\n");
    printf("\t\t\t\t\t7:输出链式线性表\n");
    printf("\t\t\t\t\t8:返回\n");
    printf("\t\t\t\t\t\t请输入您的选择(1-8)=:");
    scanf("%d",&z);
    if(z==8) break;
    switch(z)
    { case 1:printf("这里是创建链式线性表"); break;
    case 2:printf("这里是求链式线性表的长度"); break;
    case 3:printf("这里是按序号取链表元素"); break;
    case 4:printf("这里是按序号取链表元素"); break;
    case 5:printf("这里是插入元素"); break;
    case 6:printf("这里是删除元素"); break;
    case 7:printf("这里是输出链式线性表");break;
    default:printf("error"); break;}
            printf("\n");
            system("pause");
    return 1;
    }
    }
    
    

    我帮你改过,测试过了,没有问题,麻烦采纳,谢谢!

    评论
    解决 4 无用
    打赏 举报

相关推荐 更多相似问题