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