2011年软考程序员考试复习笔试知识点整理(17)

来源:软件水平考试    发布时间:2012-11-05    软件水平考试视频    评论

  for(int i = 0; i <(int)m_pSTreeRoot->Child.size(); i++)

  {

  if(i ==(int)m_pSTreeRoot->Child.size() - 1)

  {

  bIsEnd[0] = 1;

  }

  PrintNode(m_pSTreeRoot->Child[i], 1,bIsEnd);

  }

  cout << endl;

  }

  voidCSuffixTree::PrintNode(mynode p, int c, vector& isend)

  {

  for(int j=0; j

  {

  if(isend[j] == 0)

  {

  if(j != c-1)

  cout << "│";

  else

  cout << "├";

  }

  else

  {

  if(j != c-1)

  cout << " ";

  else

  cout << "└";

  if(j != c-1)

  cout << " ";

  else

  cout <<""; //最后一个

  }

  }

  cout << " " <strdata;

  //if(p->Child.size() == 0)cout <<" (" << p->nIndex << ")";

  cout << endl;

  for(int i=0; i<(int)p->Child.size();i++)

  {

  if(isend.size() == c)

  {

  isend.push_back(0);

  }

  else

  {

  isend[c]=0;

  }

  if(i == (int)p->Child.size() - 1)

  {

  if(isend.size() == c)

  isend.push_back(1);

  else

  isend[c]=1;

  }

  PrintNode(p->Child[i], c + 1,isend);

  }

  }

  //mian.cpp

  intmain(int argc, char* argv[])

  {

  string a;

  cout << "Please input astring:";

  cin >> a; //通过输入获得目标字符串a

  CSuffixTree mytree(a); //产生CsuffixTree类的实例mytree

  mytree.CreatTree(); //调用CreatTree方法创建一棵后缀树

  mytree.Show(mytree.ST); //调用Show方法输出生成的后缀树

  }

上一页456下一页

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答