系统总提示这个。。为什么error C2039: 'elme' : is not a member of 'SqList' 15
#include<stdio.h>#include<time.h>#include<stdlib.h>//----线性表的动态分配动态存储结构----#defineLIS...
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
//----线性表的动态分配动态存储结构----
#define LIST_INIT_SIZE 10
typedef struct SqList{
int * elem;
int length;
int listsize;
}SqList;
//----线性表的初始化A,B----
SqList InitListAB()
{SqList L;
int i;
int T=10+rand()%50;
L.elme=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(-1);
srand(T);
for(i=0;i<L.length;i++)
L.elem[i]=1+rand()%50;
printf("/n");
return L;
}
//----线性表的初始化C----
SqList InitListC()
{SqList L;
L.elme=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(-1);
L.length=0;
L.length=LIST_INIT_SIZE;
printf("/n");
return L;
}
//----A,B线性表的升序排列----
void ListSortUp(SqList L){
int i,j,temp;
for(i=0;i<L.length;i++)
for(j=0;j<L.length-j-1;j++) {
if(L.elem[j]>L.elem[j+1]){
temp=L.elem[j];
L.elem[j]=L.elem[j+1];
L.elem[j+1]=temp;}
}
}
//----合并线性表,并按降序排列----
SqList MergeList(SqList La,SqList Lb,SqList Lc){
int i=1,j=1,k=0;
int *pa,*pb,*pc;
int *palast,*pblast;
pa=La.elem;
pb=Lb.elem;
Lc.listsize=Lc.length;
pc=Lc.elem=(int *)malloc(Lc.listsize*sizeof(int));
if(!Lc.elem)exit(0);
palast=La.elem+La.length-1;
pblast=La.elem+Lb.length-1;
while((palast>=pa)&&(palast>=pb)){
if(*palast>=*pblast)
*pc++=*palast--;
else *pc++=*pblast--;
}
while(palast>=pa)
*pc++=*palast--;
while(pblast>=pb)
*pc++=*pblast--;
return Lc;
}
//----线性表个数输入函数----
int ScanList(SqList L){
int i;
printf("请输入顺序表的长度(0-10):");
scanf("%d",i);
printf("/n");
return i;
}
//----线性表结果的输出----
void PrintList(SqList L){
int i;
printf("Lc结果如下:");
for(i=1;i<=L.length;i++)
printf("%5d",L.elem[i]);
printf("/n");
}
//----主函数----
int main()
{
SqList La,Lb,Lc;
La=InitListAB();
Lb=InitListAB();
Lc=InitListC();
La.length=ScanList(La);
Lb.length=ScanList(Lb);
Lc.length=ScanList(La)+ScanList(La);
ListSortUp(La);
ListSortUp(Lb);
printf("La:");
PrintList(La);
printf("Lb:");
PrintList(Lb);
Lc=MergeList(La,Lb,Lc);
printf("Lc:");
PrintList(Lc);
return 0;
}
123.cpp
F:\C++程序\QWE\123.cpp(16) : error C2039: 'elme' : is not a member of 'SqList'
F:\C++程序\QWE\123.cpp(6) : see declaration of 'SqList'
F:\C++程序\QWE\123.cpp(27) : error C2039: 'elme' : is not a member of 'SqList'
F:\C++程序\QWE\123.cpp(6) : see declaration of 'SqList'
执行 cl.exe 时出错.
QWE.exe - 1 error(s), 0 warning(s) 展开
#include<time.h>
#include<stdlib.h>
//----线性表的动态分配动态存储结构----
#define LIST_INIT_SIZE 10
typedef struct SqList{
int * elem;
int length;
int listsize;
}SqList;
//----线性表的初始化A,B----
SqList InitListAB()
{SqList L;
int i;
int T=10+rand()%50;
L.elme=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(-1);
srand(T);
for(i=0;i<L.length;i++)
L.elem[i]=1+rand()%50;
printf("/n");
return L;
}
//----线性表的初始化C----
SqList InitListC()
{SqList L;
L.elme=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(-1);
L.length=0;
L.length=LIST_INIT_SIZE;
printf("/n");
return L;
}
//----A,B线性表的升序排列----
void ListSortUp(SqList L){
int i,j,temp;
for(i=0;i<L.length;i++)
for(j=0;j<L.length-j-1;j++) {
if(L.elem[j]>L.elem[j+1]){
temp=L.elem[j];
L.elem[j]=L.elem[j+1];
L.elem[j+1]=temp;}
}
}
//----合并线性表,并按降序排列----
SqList MergeList(SqList La,SqList Lb,SqList Lc){
int i=1,j=1,k=0;
int *pa,*pb,*pc;
int *palast,*pblast;
pa=La.elem;
pb=Lb.elem;
Lc.listsize=Lc.length;
pc=Lc.elem=(int *)malloc(Lc.listsize*sizeof(int));
if(!Lc.elem)exit(0);
palast=La.elem+La.length-1;
pblast=La.elem+Lb.length-1;
while((palast>=pa)&&(palast>=pb)){
if(*palast>=*pblast)
*pc++=*palast--;
else *pc++=*pblast--;
}
while(palast>=pa)
*pc++=*palast--;
while(pblast>=pb)
*pc++=*pblast--;
return Lc;
}
//----线性表个数输入函数----
int ScanList(SqList L){
int i;
printf("请输入顺序表的长度(0-10):");
scanf("%d",i);
printf("/n");
return i;
}
//----线性表结果的输出----
void PrintList(SqList L){
int i;
printf("Lc结果如下:");
for(i=1;i<=L.length;i++)
printf("%5d",L.elem[i]);
printf("/n");
}
//----主函数----
int main()
{
SqList La,Lb,Lc;
La=InitListAB();
Lb=InitListAB();
Lc=InitListC();
La.length=ScanList(La);
Lb.length=ScanList(Lb);
Lc.length=ScanList(La)+ScanList(La);
ListSortUp(La);
ListSortUp(Lb);
printf("La:");
PrintList(La);
printf("Lb:");
PrintList(Lb);
Lc=MergeList(La,Lb,Lc);
printf("Lc:");
PrintList(Lc);
return 0;
}
123.cpp
F:\C++程序\QWE\123.cpp(16) : error C2039: 'elme' : is not a member of 'SqList'
F:\C++程序\QWE\123.cpp(6) : see declaration of 'SqList'
F:\C++程序\QWE\123.cpp(27) : error C2039: 'elme' : is not a member of 'SqList'
F:\C++程序\QWE\123.cpp(6) : see declaration of 'SqList'
执行 cl.exe 时出错.
QWE.exe - 1 error(s), 0 warning(s) 展开
3个回答
2013-03-30
展开全部
'elme' : is not a member of 'SqList'
很明显你的elme拼写错误啊,错误提示那不是告诉你了,elme不是SqList的成员!
很明显你的elme拼写错误啊,错误提示那不是告诉你了,elme不是SqList的成员!
展开全部
L.elme=(int *)malloc(LIST_INIT_SIZE*sizeof(int));
if(!L.elem)exit(-1);
书写错误
if(!L.elem)exit(-1);
书写错误
追问
额。。。没错啊
追答
L.elme ==> L.elem ???
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询