数据结构.线性插入问题.For(p=&(L.elem[L.length-1]);p>=q;——p)*(p+1)=*p;我怎么感觉——p.也可以写成p——;改了有影响吗?
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/05 22:00:16
![数据结构.线性插入问题.For(p=&(L.elem[L.length-1]);p>=q;——p)*(p+1)=*p;我怎么感觉——p.也可以写成p——;改了有影响吗?](/uploads/image/z/5169979-19-9.jpg?t=%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84.%E7%BA%BF%E6%80%A7%E6%8F%92%E5%85%A5%E9%97%AE%E9%A2%98.For%28p%3D%26%28L.elem%5BL.length-1%5D%29%EF%BC%9Bp%3E%3Dq%EF%BC%9B%E2%80%94%E2%80%94p%29%2A%28p%2B1%29%3D%2Ap%3B%E6%88%91%E6%80%8E%E4%B9%88%E6%84%9F%E8%A7%89%E2%80%94%E2%80%94p.%E4%B9%9F%E5%8F%AF%E4%BB%A5%E5%86%99%E6%88%90p%E2%80%94%E2%80%94%3B%E6%94%B9%E4%BA%86%E6%9C%89%E5%BD%B1%E5%93%8D%E5%90%97%3F)
数据结构.线性插入问题.For(p=&(L.elem[L.length-1]);p>=q;——p)*(p+1)=*p;我怎么感觉——p.也可以写成p——;改了有影响吗?
数据结构.线性插入问题.
For(p=&(L.elem[L.length-1]);p>=q;——p)
*(p+1)=*p;
我怎么感觉——p.也可以写成p——;改了有影响吗?
数据结构.线性插入问题.For(p=&(L.elem[L.length-1]);p>=q;——p)*(p+1)=*p;我怎么感觉——p.也可以写成p——;改了有影响吗?
还是不明白楼主的问题,看楼主的代码没有主函数啊!根据你的代码给你写了个主函数,创建链表和输出链表都能运行.希望楼主具体说明一下你的问题
#include #include #define overflow -1#define ok 1#define error 0#define listinitsize 50#define listincrement 10typedef int status;typedef int elemtype; typedef struct lnode{ elemtype data; struct lnode *next; }lnode, *linklist;status lnitlist_l(linklist &l) //构造一个空的线性链表L{ l= (linklist)malloc(sizeof(lnode)); l->next=NULL; return ok;}//InitList_lstatus createlist_l(linklist &l){ int i,n; linklist p,q; l = (linklist)malloc(sizeof(lnode)); l->next = NULL; printf("please intput the length of the linklist:");\x09 scanf("%d",&n); printf("please intput the date of the linklist:"); p=l; for(i = 0; i < n; ++i) { q = (linklist)malloc(sizeof(lnode)); scanf("%d",&q->data); q->next=NULL; p->next=q; p =q; } return ok;}//建表 status listlength_l(linklist l){ linklist p=l; elemtype i=0; while (p->next) {p=p->next;i++;} return(i);}//求表长 status output_l(linklist l){\x09int i;\x09printf("the length of the lingklist:%d\n",listlength_l(l));\x09printf("the data of the linklist:"); linklist p; p = l->next; while(p) { printf("%d ",p->data); p = p->next; } printf("\n");\x09return ok;\x09}void main(){\x09linklist head;\x09createlist_l(head); //创建链表\x09output_l(head); //输出链表}