Pattern-MAC (PMAC) protocol, instead of having fixed sleepwakeups, the sleep-wakeup schedules of the sensor Nodes are adaptively determined. The schedules are decided based on a Node’s own traffic and that of its neighbors.
标签: sleepwakeups sleep-wakeup Pattern-MAC schedules
上传时间: 2017-08-28
上传用户:cainaifa
This book is about writing TinyOS systems and applications in the nesC language. This chapter gives a brief overview of TinyOS and its intended uses. TinyOS is an open-source project which a large number of research universities and companies contribute to. The main TinyOS website, http://www.tinyos.net, has instructions for downloading and installing the TinyOS programming environment. The website has a great deal of useful information which this book doesn’t cover, such as common hardware platforms and how to install code on a Node.
标签: This applications language chapter
上传时间: 2017-09-04
上传用户:253189838
两个链表的交集 #include<stdio.h> #include<stdlib.h> typedef struct Node{ int data; struct Node *next; }Node; void initpointer(struct Node *p){ p=NULL; } int printlist(struct Node* head){ int flag=1; head=head->next; /* 因为标记1的地方你用了头结点,所以第一个数据域无效,应该从下一个头元结点开始 */ if(head==NULL) printf("NULL\n"); else { while(head!=NULL) { if(flag==1) { printf("%d",head->data); flag=0; } else { printf(" %d",head->data); } head=head->next; } printf("\n"); } return 0; } struct Node *creatlist(struct Node *head) { int n; struct Node *p1=(struct Node *)malloc(sizeof(struct Node)); p1->next=NULL; while(scanf("%d",&n),n!=-1) { struct Node *pNode=(struct Node *)malloc(sizeof(struct Node)); pNode->next=NULL; pNode->data=n; if(head==NULL) head=pNode; p1->next=pNode; p1=pNode; } return head; } struct Node *Intersect(struct Node *head1, struct Node *head2) { struct Node *p1=head1,*p2=head2;/*我这里没有用头指针和头结点,这里是首元结点head1里面就是第一个数据,一定要理解什么事头指针, 头结点,和首元结点 具体你一定要看这个博客:http://blog.sina.com.cn/s/blog_71e7e6fb0101lipz.html*/ struct Node *head,*p,*q; head = (struct Node *)malloc(sizeof(struct Node)); head->next = NULL; p = head; while( (p1!=NULL)&&(p2!=NULL) ) { if (p1->data == p2->data) { q = (struct Node *)malloc(sizeof(struct Node)); q->data = p1->data; q->next = NULL; p->next = q;//我可以认为你这里用了头结点,也就是说第一个数据域无效 **标记1** p = q; p1 = p1->next; p2 = p2->next; } else if (p1->data < p2->data) { p1 = p1->next; } else { p2 = p2->next; } } return head; } int main() { struct Node *head=NULL,*headt=NULL,*t; //initpointer(head);//这里的函数相当于head=NULL; // initpointer(headt);//上面已经写了headt=NULL那么这里可以不用调用这个函数 head=creatlist(head); headt=creatlist(headt); t=Intersect(head,headt); printlist(t); }
标签: c语言编程
上传时间: 2015-04-27
上传用户:coco2017co
matlab有限元网格划分程序 DistMesh is a simple MATLAB code for generation of unstructured triangular and tetrahedral meshes. It was developed by Per-Olof Persson (now at UC Berkeley) and Gilbert Strang in the Department of Mathematics at MIT. A detailed description of the program is provided in our SIAM Review paper, see documentation below. One reason that the code is short and simple is that the geometries are specified by Signed Distance Functions. These give the shortest distance from any point in space to the boundary of the domain. The sign is negative inside the region and positive outside. A simple example is the unit circle in 2-D, which has the distance function d=r-1, where r is the distance from the origin. For more complicated geometries the distance function can be computed by interpolation between values on a grid, a common representation for level set methods. For the actual mesh generation, DistMesh uses the Delaunay triangulation routine in MATLAB and tries to optimize the Node locations by a force-based smoothing procedure. The topology is regularly updated by Delaunay. The boundary points are only allowed to move tangentially to the boundary by projections using the distance function. This iterative procedure typically results in very well-shaped meshes. Our aim with this code is simplicity, so that everyone can understand the code and modify it according to their needs. The code is not entirely robust (that is, it might not terminate and return a well-shaped mesh), and it is relatively slow. However, our current research shows that these issues can be resolved in an optimized C++ code, and we believe our simple MATLAB code is important for demonstration of the underlying principles. To use the code, simply download it from below and run it from MATLAB. For a quick demonstration, type "meshdemo2d" or "meshdemond". For more details see the documentation.
标签: matlab有限元网格划分程序
上传时间: 2015-08-12
上传用户:凛风拂衣袖
We consider the problem of target localization by a network of passive sensors. When an unknown target emits an acoustic or a radio signal, its position can be localized with multiple sensors using the time difference of arrival (TDOA) information. In this paper, we consider the maximum likelihood formulation of this target localization problem and provide efficient convex relaxations for this nonconvex optimization problem.We also propose a formulation for robust target localization in the presence of sensor location errors. Two Cramer-Rao bounds are derived corresponding to situations with and without sensor Node location errors. Simulation results confirm the efficiency and superior performance of the convex relaxation approach as compared to the existing least squares based approach when large sensor Node location errors are present.
标签: 传感器网络
上传时间: 2016-11-27
上传用户:xxmluo
链表习题 1. 编程实现链表的基本操作函数。 (1). void CreatList(LinkList &La,int m) //依次输入m个数据,并依次建立各个元素结点,逐个插入到链表尾;建立带表头结点的单链表La; (2). void ListPrint(LinkList La) //将单链表La的数据元素从表头到表尾依次显示。 (3).void ListInsert (LinkList &L,int i,ElemType e){ //在带头结点的单链表L中第i个数据元素之前插入数据元素e (4). void ListDelete(LinkList &La, int n, ElemType &e) //删除链表的第n个元素,并用e返回其值。 (5). int Search(LinkList L, ElemType x) //在表中查找是否存在某个元素x,如存在则返回x在表中的位置,否则返回0。 (6). int ListLength(LinkList L) //求链表L的表长 (7). void GetElem(LinkList L, int i, ElemType &e) //用e返回L中第i个元素的值 链表的结点类型定义及指向结点的指针类型定义可以参照下列代码: typedef struct Node{ ElemType data; // 数据域 struct Node *next; // 指针域 }LNode, *LinkList;
标签: 单链表
上传时间: 2017-11-15
上传用户:BIANJIAXIN
1. 编程实现链表的基本操作函数。 (1). void CreatList(LinkList &La,int m) //依次输入m个数据,并依次建立各个元素结点,逐个插入到链表尾;建立带表头结点的单链表La; (2). void ListPrint(LinkList La) //将单链表La的数据元素从表头到表尾依次显示。 (3).void ListInsert (LinkList &L,int i,ElemType e){ //在带头结点的单链表L中第i个数据元素之前插入数据元素e (4). void ListDelete(LinkList &La, int n, ElemType &e) //删除链表的第n个元素,并用e返回其值。 (5). int Search(LinkList L, ElemType x) //在表中查找是否存在某个元素x,如存在则返回x在表中的位置,否则返回0。 (6). int ListLength(LinkList L) //求链表L的表长 (7). void GetElem(LinkList L, int i, ElemType &e) //用e返回L中第i个元素的值 链表的结点类型定义及指向结点的指针类型定义可以参照下列代码: typedef struct Node{ ElemType data; // 数据域 struct Node *next; // 指针域 }LNode, *LinkList;
标签: 单链表
上传时间: 2017-11-15
上传用户:BIANJIAXIN
#include <stdio.h> #include <stdlib.h> ///链式栈 typedef struct Node { int data; struct Node *next; }Node,*Linklist; Linklist Createlist() { Linklist p; Linklist h; int data1; scanf("%d",&data1); if(data1 != 0) { h = (Node *)malloc(sizeof(Node)); h->data = data1; h->next = NULL; } else if(data1 == 0) return NULL; scanf("%d",&data1); while(data1 != 0) { p = (Node *)malloc(sizeof(Node)); p -> data = data1; p -> next = h; h = p; scanf("%d",&data1); } return h; } void Outputlist(Node *head) { Linklist p; p = head; while(p != NULL ) { printf("%d ",p->data); p = p->next; } printf("\n"); } void Freelist(Node *head) { Node *p; Node *q = NULL; p = head; while(p != NULL) { q = p; p = p->next; free(q); } } int main() { Node *head; head = Createlist(); Outputlist(head); Freelist(head); return 0; } 2.顺序栈 [cpp] view plain copy #include <iostream> #include <stdio.h> #include <stdlib.h> ///顺序栈 #define MaxSize 100 using namespace std; typedef
上传时间: 2018-05-09
上传用户:123456..
#include <iostream> #include <stdio.head> #include <stdlib.head> #include <string.head> #define ElemType int #define max 100 using namespace std; typedef struct Node1 { ElemType data; struct Node1 *next; }Node1,*LinkList;//链栈 typedef struct { ElemType *base; int top; }SqStack;//顺序栈 typedef struct Node2 { ElemType data; struct Node2 *next; }Node2,*LinkQueue; typedef struct Node22 { LinkQueue front; LinkQueue rear; }*LinkList;//链队列 typedef struct { ElemType *base; int front,rear; }SqQueue;//顺序队列 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 //1.采用链式存储实现栈的初始化、入栈、出栈操作。 LinkList CreateStack()//创建栈 { LinkList top; top=NULL; return top; } bool StackEmpty(LinkList s)//判断栈是否为空,0代表空 { if(s==NULL) return 0; else return 1; } LinkList Pushead(LinkList s,int x)//入栈 { LinkList q,top=s; q=(LinkList)malloc(sizeof(Node1)); q->data=x; q->next=top; top=q; return top; } LinkList Pop(LinkList s,int &e)//出栈 { if(!StackEmpty(s)) { printf("栈为空。"); } else { e=s->data; LinkList p=s; s=s->next; free(p); } return s; } void DisplayStack(LinkList s)//遍历输出栈中元素 { if(!StackEmpty(s)) printf("栈为空。"); else { wheadile(s!=NULL) { cout<<s->data<<" "; s=s->next; } cout<<endl; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 //2.采用顺序存储实现栈的初始化、入栈、出栈操作。 int StackEmpty(int t)//判断栈S是否为空 { SqStack.top=t; if (SqStack.top==0) return 0; else return 1; } int InitStack() { SqStack.top=0; return SqStack.top; } int pushead(int t,int e) { SqStack.top=t; SqStack.base[++SqStack.top]=e; return SqStack.top; } int pop(int t,int *e)//出栈 { SqStack.top=t; if(!StackEmpty(SqStack.top)) { printf("栈为空."); return SqStack.top; } *e=SqStack.base[s.top]; SqStack.top--; return SqStack.top; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 //3.采用链式存储实现队列的初始化、入队、出队操作。 LinkList InitQueue()//创建 { LinkList head; head->rear=(LinkQueue)malloc(sizeof(Node)); head->front=head->rear; head->front->next=NULL; return head; } void deleteEle(LinkList head,int &e)//出队 { LinkQueue p; p=head->front->next; e=p->data; head->front->next=p->next; if(head->rear==p) head->rear=head->front; free(p); } void EnQueue(LinkList head,int e)//入队 { LinkQueue p=(LinkQueue)malloc(sizeof(Node)); p->data=e; p->next=NULL; head->rear->next=p; head->rear=p; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 //4.采用顺序存储实现循环队列的初始化、入队、出队操作。 bool InitQueue(SqQueue &head)//创建队列 { head.data=(int *)malloc(sizeof(int)); head.front=head.rear=0; return 1; } bool EnQueue(SqQueue &head,int e)//入队 { if((head.rear+1)%MAXQSIZE==head.front) { printf("队列已满\n"); return 0; } head.data[head.rear]=e; head.rear=(head.rear+1)%MAXQSIZE; return 1; } int QueueLengthead(SqQueue &head)//返回队列长度 { return (head.rear-head.front+MAXQSIZE)%MAXQSIZE; } bool deleteEle(SqQueue &head,int &e)//出队 { if(head.front==head.rear) { cout<<"队列为空!"<<endl; return 0; } e=head.data[head.front]; head.front=(head.front+1)%MAXQSIZE; return 1; } int gethead(SqQueue head)//得到队列头元素 { return head.data[head.front]; } int QueueEmpty(SqQueue head)//判断队列是否为空 { if (head.front==head.rear) return 1; else return 0; } void travelQueue(SqQueue head)//遍历输出 { wheadile(head.front!=head.rear) { printf("%d ",head.data[head.front]); head.front=(head.front+1)%MAXQSIZE; } cout<<endl; } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 //5.在主函数中设计一个简单的菜单,分别测试上述算法。 int main() { LinkList top=CreateStack(); int x; wheadile(scanf("%d",&x)!=-1) { top=Pushead(top,x); } int e; wheadile(StackEmpty(top)) { top=Pop(top,e); printf("%d ",e); }//以上是链栈的测试 int top=InitStack(); int x; wheadile(cin>>x) top=pushead(top,x); int e; wheadile(StackEmpty(top)) { top=pop(top,&e); printf("%d ",e); }//以上是顺序栈的测试 LinkList Q; Q=InitQueue(); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q,x); } int e; wheadile(Q) { deleteEle(Q,e); printf("%d ",e); }//以上是链队列的测试 SqQueue Q1; InitQueue(Q1); int x; wheadile(scanf("%d",&x)!=-1) { EnQueue(Q1,x); } int e; wheadile(QueueEmpty(Q1)) { deleteEle(Q1,e); printf("%d ",e); } return 0; }
上传时间: 2018-05-09
上传用户:123456..
NodeJS开发指南中文。 本书先介绍Nodej.s,然后通过各种实例讲解Node.js的基本特性,再用案例式教学的方式讲述如何用Node.js进行web开发,等等.. 侵删,只想换点积分。。
上传时间: 2018-09-18
上传用户:chunli