#include "node.h"
#include<stdio.h>
#include<stdlib.h>
//typedef struct _node {
// int value;
// struct _node *next;
//} Node; int main(int agrc,char const *argv[])
{
int number;
Node * head = NULL;
do {
scanf("%d",&number);
if (number != -) {
//add to link list
Node *p = (Node*)malloc(sizeof(Node));
p->value = number;
p->next = NULL;
//finde the last
Node *last = head;
if (last) {
while (last->next) {
last = last->next;
}
last->next = p;
} else {
head = p;
}
}
}while (number != -);
return ;
}

加入LIST后

#include "node.h"
#include<stdio.h>
#include<stdlib.h>
//typedef struct _node {
// int value;
// struct _node *next;
//} Node;
typedef struct _list {
Node* head;
} List; void add(List* pList,int number);
int main(int argc,char const *argv[])
{
int number;
List list;
list.head = NULL;
do {
scanf("%d",&number);
add(&list,number);
} while (number != -); return ;
} void add(List* pList,int number)
{
while (number != -) {
//add to link-list
Node *p = (Node*)malloc(sizeof(Node));
p->value = number;
p->next = NULL;
// find the last
Node *last = pList->head;
if (last) {
while (last->next) {
//attach
last = last->next;
}
last->next = p;
} else {
pList->head = p;
}
}
}

最新文章

  1. MediatorPattern(中介者模式)
  2. [Ubuntu] 转载-使用Ubuntu修复grub
  3. innodB的隐式锁
  4. 小白日记9:kali渗透测试之主动信息收集(二)四层发现:TCP、UDP、nmap、hping、scapy
  5. virtualbox中ubuntu和windows共享文件夹设置
  6. oschina大数据开源软件
  7. Swift - 类的计算属性(使用get和set来间接获取/改变其他属性的值)
  8. phper談談最近重構代碼的感受(2)
  9. C++实验指导
  10. web api 路由规则和接收数据
  11. java8实战一------解决冗杂,java8真的很便利(抛砖)
  12. tomcat部署应用时设置context path为空的上下文路径问题
  13. Linux下安装jieba
  14. 常用的Lunix命令 记录
  15. [Codeforces Round #526 (Div. 2)]
  16. POJ 1144 Network(tarjan 求割点个数)
  17. ExtJS 4.2 教程-06:服务器代理(proxy)
  18. 如何在 Mac 上通过 Boot Camp 安装 Windows?
  19. Nginx upstream的5种权重分配方式【转】
  20. JDK源码分析(一)——ArrayList

热门文章

  1. Thinkphp分页时查询条件保存方法
  2. angularJS 指令二
  3. Linux用户root忘记密码的解决(unbuntu16.04)
  4. SRM 207 Div II Level Two: RegularSeason,字符串操作(sstream),多关键字排序(操作符重载)
  5. linux nadianshi
  6. SpringMVC11文件上传
  7. 后台地址报错:Service Unavailable
  8. Python 时间函数
  9. 抓取锁的sql语句-第一次修改
  10. [转载]Java synchronized详解