duoroumanggou 2021-09-17 20:24 采纳率: 66.7%
浏览 42
已结题

请问大家为什么我这个代码总说有一个错我找不到是哪里错了我是按照书上教程打的,这是数据结构与算法的题目,尽量能给我打一下代码行吗 ?因为我有点菜

#include "stdio.h"
void main()
{
    printf("hello");
}

#include "Linklistp.h"
#include "stdio.h"
void ListInitialize(SequenceList *L)
{
    L->age=0;
}
int ListLength(SequenceList L)
{
    return L.age;
}
int ListInsert(SequenceList *L,int i,ElemType x)
{
    int j;
    if(L->age>=MaxSize)
    {
        printf("顺序表无法插入\n");
        return 0;
    }
    else if(i<0||i>L->age)
    {
        printf("参数i不合法\n");
        return 0;
    }
    else
    {
        for(j=L->age;j>i;j--)
            L->list[j]=L->list[j-1];
        L->list[i]=x;
        L->age ++;
        return 1;
    }
}
int ListDelete(SequenceList *L,int i,ElemType *x)
{
    int j;
    if(L->age<=0)
    {
        printf("顺序表无数据可删\n");
        return 0;
    }
    else if(i<0||i>L->age-1)
    {
        printf("参数i不合法\n");
        return 0;
    }
    else
    {
        *x=L->list[i];
        for(j=i+1;j<=L->age-1;j++)
            L->list[j-1]=L->list[j];
            L->age--;
            return 1;
    }
}
void ListDisplay(SequenceList *L)
{
    for(int i=0;i<L->age;i++)
        cout<<L->list[j]<<'';
    printf("\n");
}
typedef int ElemType;
typedef struct 
{
    ElemType list[MaxSize];
    int age;
}SequenceList;
void ListInitialize(SequenceList *L)
int ListLength(SequenceList L)
int ListInsert(SequenceList *L,int i,ElemType x)
int ListDelete(SequenceList *L,int i,ElemType *x)
void ListDisplay(SequenceList *L)

我做的是线性表的顺序表的初始化,插入,删除,还有表的输出,如果可以的话能不能也顺便告诉我怎么把两个线性表中求2个线性表共同的元素,并输出。

Compiling.
Linklista.cpp
d:\linklistp.h(4) : error C2065: 'MaxSize' : undeclared identifier
d:\linklistp.h(4) : error C2057: expected constant expression
d:\linklistp.h(4) : warning C4200: nonstandard extension used : zero-sized array in struct/union
d:\linklistp.h(5) : error C2229: struct '__unnamed' has an illegal zero-sized array
d:\linklistp.h(8) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
d:\linklistp.h(8) : error C2146: syntax error : missing ';' before identifier 'ListLength'
d:\linklistp.h(8) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

Linklista.obj - 1 error(s), 0 warning(s)
这是编译结果

img


这是工作区

  • 写回答

1条回答 默认 最新

  • orange4reg 2021-09-17 22:27
    关注

    代码那么长,最起码给个运行截图,有输入有输出 然后说一下运行的结果哪里有问题,这样人家就好找代码的问题

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 2月16日
  • 修改了问题 9月18日
  • 创建了问题 9月17日

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值