单链表的建立
来源:互联网 发布:oracle灾备数据库 编辑:程序博客网 时间:2024/05/17 01:21
/*******************************/
/*tn10000@126.com/ */
/*******************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct node
{
int num;
struct node* next;
};
struct node * create(struct node *head);
void print(struct node *head);
int main(){
struct node *head;
head = NULL;
head = create(head);
print(head);
return 0;
}
struct node *create(struct node *head){
int i=0;
struct node *p1, *p2;
p1 = p2 = (struct node*)malloc(sizeof(struct node));
memset(p1, 0, sizeof(struct node));
scanf("%d", &p1->num);
p1->next=NULL;
while(p1->next>0){
if (head==NULL){
head=p1;
}else{
p2->next=p1;
}
p2=p1;
p1=(struct node*)malloc(sizeof(struct node));
memset(p1, 0, sizeof(struct node));
scanf("%d", &p1->num);
p1->next=NULL;
i++;
}
printf("\n total:%d\n", i);
return head;
}
void print(struct node *head){
struct node *temp;
temp = head;
while(temp != NULL){
printf("%6d\n", temp->num);
temp=temp->next;
}
}
- 单链表的建立
- 单链表的建立
- 单链表的建立
- 单链表的建立
- 循环单链表的建立
- 单链表的建立程序
- 单链表的建立
- 单链表的建立
- 建立排序的单链表
- 单链表的建立
- 有序单链表的建立
- 单链表的建立
- 单链表的建立
- 单链表的建立
- 单链表的建立
- 单链表的建立
- 单链表的建立
- 单链表(单链表的建立)
- gvim的配置
- display:inline-block的深入理解
- 2.1. Android的第一个例子(续)
- IS08583报文协议包的解析和封装java源代码 【转】
- 选中gridview中的某一行或多行,实现删除
- 单链表的建立
- javascript验证表单格式
- 使用存储过程实现数据的交换
- 非常好的一篇讲c++学习方法的文章
- js简体繁体转换
- C++外部函数
- uva 10913 Walking on a Grid
- JS实现表格排序
- USACO Section 2.3 Controlling Companies - 题意要理解清楚..