求链表长度
来源:互联网 发布:千牛卖家数据访客 编辑:程序博客网 时间:2024/04/29 05:03
//求链表长度
#include<stdio.h>
#include<stdlib.h>
typedef struct No{
int date;
No* next;
} Node;
Node *creat()
{
Node *head=NULL,*p,*tail;
int x;
scanf("%d",&x);
while(x!=-1){
p=(Node*)malloc(sizeof(Node));
p->date=x;
p->next=NULL;
if(head==NULL)
tail=head=p;
else{
tail->next=p;
tail=p;
}
scanf("%d",&x);
}
return head;
}
int count(Node* head)
{
int sum=0;
Node* p=head;
while(p!=NULL){
sum++;
p=p->next;
}
return sum;
}
main()
{
Node *head;
head=creat();
printf("%d/n",count(head));
return 0;
}
- 求链表长度
- 求链表的长度
- 长度
- 求链表长度的函数的问题
- 获取字符串长度、字符长度、字节长度
- 获取字符串长度、字符长度、字节长度
- 创建单链表,求链表长度、查找、插入、删除、合并。
- 字符串长度
- 长度换算
- 长度、宽度
- 长度(length)
- 长度单位
- 取长度
- N50 长度
- 字符长度
- URL长度
- 字符串长度
- 数据类型长度
- matlab 中配置libsvm 的方法。。。。
- android小菜入门详解
- 客户区窗口动态分割示例
- wince开机画面
- android Menu和android Intent使用。
- 求链表长度
- Oracle PGA详解
- MapGIS6x-2--类库开发介绍
- Get和Post的区别
- Intent传值
- OGRE -- HardwareBuffer创建Mesh
- MapGIS6x-2-开发环境设置
- fastdb学习总结
- 两个有序数列的合并(链表的应用)(4)