我写了一个顺序表的简单操作, 一直不理解这个指针的用法。
#include <stdio.h>
#include <stdlib.h>
#define LIST_MAX 10
typedef struct {
int List_data[LIST_MAX];
int Lenth;
}SqrList;
void List_insert(SqrList &L,int NUM, int Change)
{
for(int j=L.Lenth;j>=NUM;j-- )
{
L.List_data[j] = L.List_data[j-1];
}
L.List_data[NUM-1] = Change;
L.Lenth++;
}
void List_Init(SqrList &L )
{
L.Lenth = 6 ;
for(int i = 0; i<L.Lenth;i++)
{
L.List_data[i] = 0;
}
}
void List_printf(SqrList &L)
{
for(int i=0;i<L.Lenth;L++)
{
printf("顺序表的第%d个的值:%d",i,L.List_data[i]);
}
}
int main()
{
SqrList L;
List_Init(L);
List_printf(L);
List_insert(L,5,4);
List_printf(L);
return 0;
}
error: expected ';', ',' or ')' before '&' token|
error: expected ';', ',' or ')' before '&' token|
为什么会报这个错误呀?
#include <stdlib.h>
#define LIST_MAX 10
typedef struct {
int List_data[LIST_MAX];
int Lenth;
}SqrList;
void List_insert(SqrList &L,int NUM, int Change)
{
for(int j=L.Lenth;j>=NUM;j-- )
{
L.List_data[j] = L.List_data[j-1];
}
L.List_data[NUM-1] = Change;
L.Lenth++;
}
void List_Init(SqrList &L )
{
L.Lenth = 6 ;
for(int i = 0; i<L.Lenth;i++)
{
L.List_data[i] = 0;
}
}
void List_printf(SqrList &L)
{
for(int i=0;i<L.Lenth;L++)
{
printf("顺序表的第%d个的值:%d",i,L.List_data[i]);
}
}
int main()
{
SqrList L;
List_Init(L);
List_printf(L);
List_insert(L,5,4);
List_printf(L);
return 0;
}
error: expected ';', ',' or ')' before '&' token|
error: expected ';', ',' or ')' before '&' token|
为什么会报这个错误呀?
...全文
相关推荐
头歌数据结构顺序表的基本操作1-6关
头歌数据结构顺序表的基本操作1-6关 第1关:顺序表的插入操作 第2关:顺序表的删除操作 第3关:顺序表的按照序号查找值操作 第4关:顺序表的按照值查找序号操作 第5关:顺序表的逆置操作 第6关:两个有序顺序表的合并操作 稳过
顺序表和链表的指针区别
顺序表和链表中 指针的不同用法 尤其在循环遍历中的细节
编写函数,建立一个顺序表并输出,计算该顺序表的长度。 实现在顺序表中查找第i个元素的值。实现在顺序表中第i个位置上插入值为x的
学生代码作业
如何在C++中建立一个顺序表
在使用顺序表之前,首先创建一个空的顺序表,也就是初始化顺序表。这里,在程序中只需设置顺序表的结点数量ListLen为0即可。这样,后面需要添加的数据元素将从顺序表的第一个位置存储
头歌 顺序表,链表,循环队列的基本操作和应用答案。
头歌数据结构的题目: 顺序表的基本操作和应用 链表的基本操作和应用, 循环队列的应用 同时还有一些附加题,n皇后和钓鱼



