本文整理汇总了C++中Tree::Find方法的典型用法代码示例。如果您正苦于以下问题:C++ Tree::Find方法的具体用法?C++ Tree::Find怎么用?C++ Tree::Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tree
的用法示例。
在下文中一共展示了Tree::Find方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TestGrandfather
void TestGrandfather()
{
cout << "TestGrandfather()--------------------------------------------------" << endl;
t1.Print();
//int x = 6;
//cout << t1.Find(x) << endl;
int x = 3;
int y = 6;
t1.GetNearestGandfather(t1.Find(x),t1.Find(y));
}
示例2: Enquire_MST
void Enquire_MST(Graph& g, Tree& tree)
{
bool* flag = new bool[g.m_v];
double* d = new double[g.m_v];
int* q = new int[g.m_v];
int* src = new int[g.m_v];
//初始化flag, d ,q, src
for(int i = 0;i < g.m_v;i++)
{
flag[i] = false;
d[i] = INT_MAX;
q[i] = -1;
src[i] = -1;
}
int s = 0;
for(int i = 0;i < g.m_v;i++)
if(g.m_hash[i])
{
s = i;break;
}
//将点0加入点集V
Update(g, flag, s, d, q, src);
tree.m_id = s;
double min = 0;
Tree* temp = NULL;
Tree* node = NULL;
for(int i = 1;i < g.m_v;i++)
{
//选出V'中离V最近的点s,边用q[s]表示
min = INT_MAX;
s = -1;
for(int j = 0;j < g.m_v;j++)
if(g.m_hash[j])
if(!flag[j])
if(d[j] < min)
{
min = d[j];
s = j;
}
if(s == -1) break;
temp = tree.Find(src[s]);
node = new Tree(s);
node->m_weight = q[s];
if(temp->m_son == NULL)
temp->m_son = node;
else
{
node->m_brother = temp->m_son;
temp->m_son = node;
}
Update(g, flag, s, d, q, src);
}
}
示例3: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
Tree<int>* tr = new Tree<int>();
tr->Add(123, "abcdef");
tr->Add(456, "abde");
tr->Add(789, "aaaa");
tr->Add(145, "a");
tr->Add(464, "ab");
tr->Print("Tree");
cout << endl;
tr->Add(444, "a");
cout << endl;
tr->Find("abde");
cout << endl;
tr->Delete("abde");
tr->Print("After deleting record (key - abde)");
getchar();
return 0;
}
示例4: printWelcome
void printWelcome(){
Menu welcome("BLACK","BLUE","RED", 50,17,15,2);
char ID[20];
char passtemp[10];
char idtemp[10];
char subtemp;
int password=0;
COORD position;
position.X=27;
position.Y=5;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
cout << "Welcome To First Last Bank!";
position.X+=3; position.Y+=4;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
cout << "Enter ID: ";
position.Y+=2;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
cout << "Enter Password: ";
position.X+=10; position.Y-=2;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
for(int i=0; i<8; i++)
{
subtemp=getch();
if(i==0 && toupper(subtemp) >=65 && toupper(subtemp) <=90)
{
cout << (char)toupper(subtemp);
idtemp[i]= (char)toupper(subtemp);
}
else if(i>=1 && subtemp>=48 && subtemp<=57)
{
idtemp[i] = subtemp;
cout << subtemp;
}
else
i--;
}
idtemp[i]='\0';
strcpy(ID,idtemp);
::found = FBLTree.Find(ID);
position.X+=6; position.Y+=2;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position);
for( i=0; i<4; i++)
{
subtemp=getch();
if(subtemp>=48 && subtemp<=57)
{
passtemp[i] = subtemp;
cout << "*";
}
else
i--;
}
password=atoi(passtemp);
if(::found!=NULL && stricmp(::found->ID,ID)==0 && ::found->password==password)
{
::counter=0;
printMenu();
}
else
{
::counter++;
if(::counter == 3)
{
system("cls");
printWarning();
//.........这里部分代码省略.........
示例5: main
int main()
{
//cout<<"please enter today date (day,month and year seperated by spaces) : "<<endl;
//cin>>D>>M>>Y;
string user;
cout<<"Enter Your Name:";cin>>user;
cout<<"hello "<<user<<" !"<<endl;
Tree FileSystem;
//initalize the tree with folder called first folder
FileSystem.IntializeTheTree("root","folder",FileSystem.root);
cout<<"Manual [instructions examples]"<<endl;
cout<<"*********************"<<endl;
cout<<"#Create: create folder folderName in root"<<endl;
cout<<"_____"<<endl;
cout<<"#Update: update folderName r true"<<endl;
cout<<"#Update: update folderName w true"<<endl;
cout<<"#Update: update folderName e true"<<endl;
cout<<"#Update: update folderName owner ahmed"<<endl;
cout<<"#Update: update folderName name myfolder"<<endl;
cout<<"_____"<<endl;
cout<<"#select: select folderName"<<endl;
cout<<"_____"<<endl;
cout<<"#Depth first search: DFS"<<endl;
cout<<"#Bredth first search: BFS"<<endl;
cout<<"_____"<<endl;
cout<<"output: out"<<endl;
cout<<"***********************"<<endl;
string cmd,first,second,third,parent;
while(1)
{
FILE *stream ;
cin>>cmd;
if(cmd=="end"){break;}
else if(cmd=="out")
{
if((stream = freopen("output.xml", "w", stdout)) == NULL)
exit(-1);
//freopen("A-small-attempt0.in","r",stdin);
//freopen("output.xml","w",stdout);
FileSystem.xml(FileSystem.root);
//freopen ("/dev/tty", "a", stdout);
}
else if(cmd=="DFS")
{
FileSystem.DFS(FileSystem.root);
}
else if(cmd=="BFS")
{
FileSystem.BFS(FileSystem.root);
}
else if(cmd=="select")
{
stream = freopen("CON", "w", stdout);
cin>>first;
FileSystem.Find(first,FileSystem.root);
}
else if(cmd=="update")