QM算法

  • 格式:pdf
  • 大小:121.15 KB
  • 文档页数:16
Node *p = new Node; temp = temp->next; p->number = temp->number; zemp->next = p; zemp = p; } temp = y->head; while(temp->next!=NULL) { Node *q = new Node; temp = temp->next; q->number = temp->number; zemp->next = q; zemp = q; } zemp->next = NULL; }
{ int nums = 0; int i = 0; while(i<lines) { if(A[i]->head->number!=u) ++nums; ++i; } return nums;
}
//链表
static void Copy(List* x, List* y, int bit) 到y
{ Node *str = new Node; str->number = x->head->number;
static void Combine(List* x, List *y, List *z, int change, int bit) //将x与y合为一个链表z
{
Node *str = new Node; str->number = x->head->number;
int i=0; while(i<bit) {
}
static void Pickup(int **table, int *pick, int m_count, int total) //pick[]记录本质本源蕴含项对应的列表
{ int k = 0; for(int j=0; j<m_count; j++) { int num = 0; for(int i=0; i<total; i++) { if(table[i][j]==1) { pick[k] = i; ++num; } if(num>1) { i = total; pick[k] = -1; } } ++k; }
static void DeleList(List *x) {
Node *p = x->head; Node *q = p->next; while(p->next!=NULL) {
delete p; p = q;
q = q->next; } delete p; }
static void Essent(int **table, const unsigned int* m, unsigned int m_count, List **T, int total)
Node *str = new Node; str->number = 1; A[0][i] = new List; A[0][i]->head = str; A[0][i]->q = new int[bits];
Node *p = new Node; A[0][i]->head->next = p; p->next = NULL; A[0][i]->q = new int[bits]; if(i < (int)m_count) {p->number = m[i]; MyCode::Exchange(A[0][i]->q, m[i], bits);} else {p->number = d[i-m_count]; MyCode::Exchange(A[0][i]->q, d[i-m_count], bits);} } int select = num; int mid ; //需要构造的Size2 蕴含项链表的个数 int times = 2;
select = spec; ++t; } else { record = t; t=10; } times = times *2; }
int i; int **table = new int*[select]; for(i=0; i<select; i++) {
table[i] = new int[m_count]; for(unsigned int j=0; j<m_count; j++) {
return "";//??返回自己的学号
}
static std::string QM(const unsigned int* m, unsigned int m_count,
const unsigned int* d, unsigned int d_count) {
int bits = MyCode::FindBit(m, m_count, d, d_count); int num = m_count + d_count; List ***A = new List** [10]; A[0] = new List* [num]; for(int i=0; i<num; i++) {
if(i==change) {z->q[i] = 9; ++i;} else {z->q[i] = x->q[i]; ++i;}
} z->head = str; Node *temp = x->head; Node *zemp = z->head; while(temp->next!=NULL) {
//将x复制
y->head = str;
for(int i=0; i<bit; i++) {
y->q[i] = x->q[i]; } Node *help = x->head; Node *yelp = y->head; while(help->next!=NULL) {
Node *need = new Node; help = help->next; need->number = help->number; yelp->next = need; yelp = need; } yelp->next = NULL; }
}
static void Exchange(int* need, int deci, int bit) // 十进制转二进制数
{ int i = 0;
if(deci==0) {
while(i<bit) {
need[i] = 0; ++i; } } else { while(deci>1) { int reminder = deci%2;
// MyCode.hpp的使用: // 直接把MyCode.hpp当做普通头文件来使用就可以了。实际上hpp 就是.cpp和.h的合并。 #include <string> #include <list> #include <vector> #include <iostream> #include <algorithm>
if(chact!=0) last = last + "+"; chact++; int row = esse[i]; last = last + MyCode::Translate(A[record][row]->q, bits); for(int i=0; i<(int)m_count; i++) {
{ int i = 0; while(i<total) { Node *p = new Node; p = T[i]->head; while(p->next!=NULL) { Node * q = p->next; int j = 0; while(j <(int) m_count) { if(q->number==m[j]) { table[i][j]=1; j = m_count; } else ++j; } p = q; } ++i; }
deci = deci/2; need[i] = reminder; ++i; } need[i] = 1; ++i; while(i<bit) { need[i]=0; ++i; } } }
static int Compare(int *a, int *b, int bit) 制位数差
{ int i = 0; int j = 0; int k = 99;
if(table[i][s]==1) {
if(chact!= 0) last = last + "+"; chact++;
last = last + MyCode::Translate(A[record][i]->q, bits);
for(int j=0; j<(int)m_count; j++) { if(table[i][j]==1) Saber[j] = 1; } i = -1;
int t = 0 ; int record; while(t<10)
{
mid = MyCode::Filter(A[t], select, bits, times); if(mid!=0) {
int row = MyCode::Calculate(A[t], select, times); int total = row + mid; A[t+1] = new List*[total];