C语言 结构体 链表问题 急急急急急急

作者&投稿:冷冰 (若有异议请与网页底部的电邮联系)
c语言链表结构体的问题~

结构体定义指针应该是这样的: node *p;或者struct Node *p;
在定义/声明函数时,void as(struct node *p);这样是不对的。应该是这样:
void as(struct Node *p);
或者
void as(node *p);
函数调用的时候不用指针直接放入结构体该是这样调用的:
node stnod;
as(&stnod);
它和
node stnod,*p_stnod;
p_stnod=&stnod;
as(p_stnod);
作用是一样的。

stl呀,里面有很多,都封装好了,效率也很高,
list,vector,deque,stack,map等等
头文件名称和类名称一样,比如list为
#include
map为
#include
最好使用一下std命名空间,因为所有类再std命名空间下
using namespace std;

STU = struct student,
在输入的时候,要么是struct student ×head 要么是 STU *head

1 解决方案:去掉第二张图里面前面的struct STU的srtruct 就可以了
2 原因:STU 相当于一个数据类型,直接使用就可以了,不同加struct


汉源县15643139632: c语言链表结构体问题 -
符申山荷: 结构体定义指针应该是这样的: node *p;或者struct Node *p; 在定义/声明函数时,void as(struct node *p);这样是不对的.应该是这样: void as(struct Node *p); 或者 void as(node *p); 函数调用的时候不用指针直接放入结构体该是这样调用的: node stnod; as(&stnod); 它和 node stnod,*p_stnod; p_stnod=&stnod; as(p_stnod); 作用是一样的.

汉源县15643139632: C语言(结构体和链表问题) -
符申山荷: 这个函数最好把数组的长度作为参数传进来.看看这个能不能满足你的要求#include <stdio.h> struct bookdata *Link(struct bookdata data[], int data_len) { int i; for (i = 0; i < data_len; i++) data[i].next = data + i + 1; data[data_len].next = NULL; /* 最后一个指向null */ return data; }

汉源县15643139632: c语言问题,急急急!关于链表的!题目是这样的:链表练习:求集合的差:假设集合A用单链表LA表示,集合B用单链表LB表示,设计算法求两个集合的差... -
符申山荷:[答案] #include #include typedef struct list{ int elem;//存数链表节点的元素值 struct list *next;//指向下一节点 }LIST; LIST *createlist(int n) { LIST *head,*p,*p1; int i; head=(LIST *)malloc(sizeof(LIST)); p=head; scanf("%d",&(p->elem)); p->...

汉源县15643139632: 谁能提供一个C语言结构体实现链表的例子,代码能直接运行的? -
符申山荷: //输入四个数字,存入单链表,然后显示出来.有任何问题,就追问我,我还是挺厚道滴... #include "stdio.h" #include "malloc.h" struct node{ int data; struct node * next;}; struct node * head = ( struct node *) malloc ( sizeof( node)); //头插...

汉源县15643139632: c语言结构体数组,链表的问题~~~请进 -
符申山荷: link *hcreat() { link *s,*p; elemtype i; cout<<"输出多个结点数值(用空格分隔),为0时算法结束"; cin>>i; p=new link; p->next=NULL; while(i)//循环建立链表 { s=new link; s->data=i; s->next=p->next; p->next=s; cin>>i;} return p;}你的链表建立有问题

汉源县15643139632: 急救!!C语言一道关于结构体链表的填空题,就一个空 -
符申山荷: 上面那位大哥,你出现了一个小错误,我改了一下p = pa; //将p指针指向首地址 printf("%c", p.value); 不知你结构另外一个成员是哪个,就当value了,别的你改 p = p->next; //1楼指针应该用指针成员

汉源县15643139632: 求大哥大姐帮忙解决下链表问题C语言的.3.定义结点如下形式:struct menu{char name;int no;struct menu *next;};进行如下操作:(1) 建立一个长度为... -
符申山荷:[答案] 楼主你好 具体代码如下:#include#include#define MAX 20 typedef struct menu{ char name[20]; int no; struct menu *next;}List; void Creat_List(List * &h){ List *p;//用于插入 List *r=h;//尾指针 开始指向头...

汉源县15643139632: C语言 结构体 链表 -
符申山荷: 这是一个完全没有错误的程序#include<stdio.h>#include<stdlib.h>#include <malloc.h>#define ElemType int#define OK 1#define ERROR 0 typedef struct Node { ElemType data; struct Node *next; } Node,*LinkList;//初始化单链表 void InitList(...

汉源县15643139632: 急~~~数据结构用C语言创建链表 -
符申山荷: #include<stdio.h>#include<stdlib.h> typedef struct node *pointer; struct node { int data; pointer next; }; pointer next,null,p,L,s,q; int j,e,n,k; creater(int n) { int i; L=(struct node *)malloc(sizeof(struct node)); L->next-null; s=L; for(i=1;i<=n;i++) {printf("\n输...

汉源县15643139632: C语言中链表中的结构体指针变量问题...求教 -
符申山荷: 定义结构体指针变量时,只分配存储指针类型需要的空间,比如ListNode *p;这里p有给他分配存储指针的4个字节的空间.实际上你是要让p指向一个结构体空间的,这个结构体空...

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网