| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1073 人关注过本帖
标题:第一次敲线性表的代码 全是问题
只看楼主 加入收藏
月祭樱冢
Rank: 2
等 级:论坛游民
帖 子:83
专家分:97
注 册:2013-7-15
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:16 
第一次敲线性表的代码 全是问题
题目是删除线性表中元素值在【x,y】之间的元素。
这是参照书自己写的
程序代码:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define i 0

void CreateList(SqList *&L,int a[],int n)
{
    L=(SqList *)malloc(sizeof(SqList));
    for(;i<n;i++)
        L->data[i];
    L->length=n;[i]=a
}

int LocateElem(SqList *L,int e)
{
    while(i<L->length && L->data[i]!=e)
        i++;
    if(i>=L->length)
        return 0;
    else
        return i+1;
}

bool ListDelete(SqList *&L,int i,int t)
{
    int j;
    if(i<1 || i>L->length)
        return false;
    i--;
    for(j=i;j<L->length-t;j++)
        L->data[j]=L->data[j+t];
    L->length-=t;
    return ture;
}

void DispList(SqList *L)
{
    for(;i<L->length;i++)
        printf("%d",L->data[i]);
    printf("\n");
}

int main()
{
    void CreateList(SqList *&L,int a[],int n);
    int LocateElem(SqList *L,int e);
    bool ListDelete(SqList *&L,int i,int t);
    void DispList(SqList *L);
    int m,n,a[100],x,y,l;
    bool b;
    printf("请输入顺序数组a:\n");
    for(;i<100;i++)
    {
        scanf("%d",a[i]);
        if(a[i]=='\n') break;
    }
    printf("x=");
    scanf("%d",x);
    printf("y=");
    scanf("%d",y);
    l=strlen(a);
    CreateList(L,a[l],l);
    n=LocateElem(L,x);
    m=LocateElem(L,y);
    m=m-n-1;
    b=ListDelete(L,n,m);
    if(b==ture)
        DDispList(L);
    else
        printf("删除失败!\n");
    return 0;
}

这是编译器报的错  好多啊
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(6) : error C2143: syntax error : missing ')' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(6) : error C2143: syntax error : missing '{' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(6) : error C2059: syntax error : '&'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(6) : error C2059: syntax error : ')'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(14) : error C2143: syntax error : missing ')' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(14) : error C2143: syntax error : missing '{' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(14) : error C2059: syntax error : 'type'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(14) : error C2059: syntax error : ')'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(24) : error C2061: syntax error : identifier 'ListDelete'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(24) : error C2059: syntax error : ';'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(24) : error C2143: syntax error : missing ')' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(24) : error C2143: syntax error : missing '{' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(24) : error C2059: syntax error : '&'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(24) : error C2059: syntax error : ')'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(36) : error C2143: syntax error : missing ')' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(36) : error C2143: syntax error : missing '{' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(36) : error C2059: syntax error : ')'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(37) : error C2054: expected '(' to follow 'L'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(45) : error C2143: syntax error : missing ')' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(45) : error C2143: syntax error : missing ';' before '*'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(45) : error C2059: syntax error : 'type'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(45) : error C2059: syntax error : ')'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(46) : error C2143: syntax error : missing ';' before 'type'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(47) : error C2065: 'bool' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(47) : error C2146: syntax error : missing ';' before identifier 'ListDelete'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(47) : warning C4013: 'ListDelete' undefined; assuming extern returning int
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(47) : error C2065: 'SqList' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(47) : error C2297: '*' : illegal, right operand has type 'int ** '
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(47) : error C2059: syntax error : 'type'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(48) : error C2143: syntax error : missing ';' before 'type'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(49) : error C2143: syntax error : missing ';' before 'type'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(50) : error C2146: syntax error : missing ';' before identifier 'b'
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(50) : error C2065: 'b' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(52) : error C2105: '++' needs l-value
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(54) : error C2065: 'a' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(54) : error C2109: subscript requires array or pointer type
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(55) : error C2109: subscript requires array or pointer type
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(58) : error C2065: 'x' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(60) : error C2065: 'y' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(61) : error C2065: 'l' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(61) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(61) : warning C4024: 'strlen' : different types for formal and actual parameter 1
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(62) : error C2109: subscript requires array or pointer type
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(63) : error C2065: 'n' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(63) : warning C4013: 'LocateElem' undefined; assuming extern returning int
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(64) : error C2065: 'm' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(67) : error C2065: 'ture' : undeclared identifier
D:\Microsoft Visual Studio\线性表P61T2.2\P61T2-2.c(68) : warning C4013: 'DDispList' undefined; assuming extern returning int
执行 cl.exe 时出错.
搜索更多相关主题的帖子: 线性表 color 元素 
2013-11-12 23:13
pauljames
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:千里冰封
威 望:9
帖 子:1555
专家分:10000
注 册:2011-5-8
收藏
得分:2 
都是中文符号吧,这个括号看起来就很怪异

经常不在线不能及时回复短消息,如有c/单片机/运动控制/数据采集等方面的项目难题可加qq1921826084。
2013-11-13 06:43
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:2 
看到第四行就不用往下看了

总有那身价贱的人给作业贴回复完整的代码
2013-11-13 08:13
pink_duo
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
帖 子:209
专家分:1054
注 册:2013-11-5
收藏
得分:2 
SqList 是什么?

埋头做牛,抬头做人,低头做狗
2013-11-13 09:06
月祭樱冢
Rank: 2
等 级:论坛游民
帖 子:83
专家分:97
注 册:2013-7-15
收藏
得分:0 
回复 2楼 pauljames
这点我特别注意了的

算法是程序的灵魂
2013-11-13 09:17
月祭樱冢
Rank: 2
等 级:论坛游民
帖 子:83
专家分:97
注 册:2013-7-15
收藏
得分:0 
回复 3楼 embed_xuel
能不能帮说下具体问题呢

算法是程序的灵魂
2013-11-13 09:17
pangshch
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:2
帖 子:443
专家分:1966
注 册:2013-4-9
收藏
得分:2 
链表的结构都没定义.
再把书看一遍.
然后把上面的代码删了重写.
2013-11-13 10:09
azzbcc
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:江西财经大学
等 级:贵宾
威 望:81
帖 子:3293
专家分:12919
注 册:2012-11-4
收藏
得分:2 
什么是宏?


[fly]存在即是合理[/fly]
2013-11-13 12:35
wwfdzh2012
Rank: 2
等 级:论坛游民
帖 子:88
专家分:27
注 册:2012-11-22
收藏
得分:2 
C语言不好好学,现在知道痛苦了吧
2013-11-13 14:00
月祭樱冢
Rank: 2
等 级:论坛游民
帖 子:83
专家分:97
注 册:2013-7-15
收藏
得分:0 
回复 8楼 azzbcc
c++里面的吧  还没学

算法是程序的灵魂
2013-11-13 21:56
快速回复:第一次敲线性表的代码 全是问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013942 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved