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)); }
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); } }
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; }
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: "******"*"; } 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(); } position.X-=33; position.Y+=10; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),position); cout << "Either the user or passwrod is incorrect, please try it again! " ; printWelcome(); } }
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")