自動測試二項堆的插入和彈出

2021-06-02 13:36:58 字數 2650 閱讀 4746

#include  

#include  

#include  

#define  nil  10000

#define  max  10000

#define   rand   10000

typedef  struct  _binheap

binheap;

typedef  struct  _wrapbinheap 

wrapbinheap;

wrapbinheap  global[rand];

wrapbinheap  *head;

wrapbinheap  *tail;

wrapbinheap  *global_node;

void  binheap_init( )

head=&global[0];

tail=&global[rand-1];

}binheap  *mycalloc ( )

void  myfree (binheap  *node)

binheap  *  newconstruct ( int key)

binheap  *  nilconstruct ()

else

return  nilobj;

}binheap * binheap_merge ( binheap *left , binheap *right )

if( !right)

if( left->degree < right->degree)

else

}void  re_link (binheap *left , binheap *right )

binheap * binheap_union ( binheap *left , binheap *right )

if(! x->sib)

else

else

else

}else

else

}else

}}}  

}return  wrap_head->sib;

}void binheap_insert (binheap  *newobj ,binheap * * head)

else

}void  print(binheap *head,int level)

else

}binheap  *reverse ( binheap  *head)

while( head->sib )

head->sib=left;

return  head;

}void  binheap_fix_parent (  binheap * parent_child  ,binheap *parent)

}binheap  * binheap_pop (binheap  **_head )

head=head->sib;

}wrap_head->sib=*_head;

head=wrap_head;

while(head)

head=head->sib;

}*_head=wrap_head->sib;

result=min;

binheap_fix_parent(min->child ,null);  //add  by chenbing

head= reverse  ( min->child);

*_head=binheap_union (head ,*_head);

result->sib=null;

result->child=null;

return  result;

}void  binheap_re_sib ( binheap *obj , binheap * parent_child ,binheap  *replace  )

parent_child=parent_child->sib;}}

void  binheap_adjust ( binheap * obj ,binheap  **head )

else

if( parent->parent)

else

}else

else

}parent->parent=obj;

parent->child=obj_child;

parent->sib=obj_sib;

binheap_fix_parent ( obj->child , obj);

binheap_fix_parent ( obj_child , parent);

degree=obj->degree;

obj->degree=parent->degree;

parent->degree=degree;

}else

parent=obj->parent;}}

void  binheap_dec ( binheap *obj ,int  value ,binheap  **head)

void  binheap_delete ( binheap *obj ,binheap **head )

int main()

;binheap_init( );

while(1)

while(binheap_count >  rand *1/3)}//

print(head,0);

}

簡單的自動測試系統

最近,在公司製作乙個自動測試系統,能夠把測試的資料傳輸到計算機上,第一款產品已經完成了,用買來的pci資料採集卡 qt5.0,設計了乙個簡單的顯示介面,算是完成了。但是,pci卡用起來太難受,想換一種方便 簡單一點的。所以想到了串列埠和區域網的形式 1 串列埠就是用微控制器將ad資料採集出來,然後傳...

插入和列印功能完備的二項堆

其中在union時時候故意加的wrap head很有意義,另外列印階段採用的是深度優先,還能列印合理的層數.include include define nil 9999 typedef struct binheap binheap binheap newconstruct int key binh...

C 自動測試的乙個模板

一 表結構 mysql select from users id name passwd 001 bzcyer 123456 002 jerry 111111 2 rows inset 0.03 sec 二 測試 三 1 將測試案例寫到testcase.txt中。如 001 bzcyer 12345...