回 帖 发 新 帖 刷新版面

主题:跪求严慰敏《数据结构》习题集,不是答案!!!...

如题....

回复列表 (共107个回复)

41 楼

楼主,你好,新手上路!也想来一份上面的东东!
感激不尽!!
wanghuipeng1027@126.com
very 谢谢拉!!!!!!!!!!!

42 楼

我谁能帮我写一个关于二叉树的主程序吗?要求有选择功能!
非常感谢!!
  
 
 

作者:flairivy
专家分:30
 
 会员信息
 发短消息  
 所属BLOG  
 发表时间:2006-12-3 9:45:00    [回复]  [引用] 
1 楼  

void main()
{ BT bt;
      int choice;
      bool t=true;

    while(t)
    {
        cout<<"1.生成二叉树\n";
        cout<<"2.先序遍历\n";
             cout<<"3.中序遍历\n";
        cout<<"4.后序遍历\n"; 
            cout<<"5.层次遍历\n";
        cout<<"6.计算二叉树结点数目 \n"; 
        cout<<"7.计算二叉树高度\n"; 
        cout<<"8.删除指定元素\n";
        cout<<"9.给出二叉树的前序和中序,输出它的后序\n";
        cout<<"请选择操作"<<endl;
        cin>>choice;
       switch(choice)
        {
        case 1:{bt.CreateBT(&bt.root);
               break;}
        case 2:{    
            if (bt.root ==NULL)
               cout<<"二叉树为空,请先创建/n";
          else
            bt.preorder(bt.root);
            break;
               }
        case 3:{
            if (bt.root ==NULL)
               cout<<"二叉树为空,请先创建/n";
          else
            bt.inorder(bt.root);
            break;
               }
        case 4:{
            if (bt.root ==NULL)
               cout<<"二叉树为空,请先创建/n";
          else
            bt.postorder(bt.root);
            break;
               }
        case 5:{bt.translever(bt.root);
            break;}
        case 6:{
            bt.jiediannumber(bt.root);
            cout<<"结点数为:"<<count<<endl;
                        count=0;
            break;}
        case 7:{cout<<"高度度为"<<bt.depth(bt.root)<<endl;
            break;}
        case 8:{cout<<"你创建的二叉树按照前序遍历为:\n";
               bt.preorder (bt.root );
                cout<<"\n";
            cout<<"请输入你要删除的节点的数值"<<endl;
                int d;
                cin>>d;
                bt.Delete(&bt.root,d);
                if(find==false) cout<<"没有你要删除的节点 ";
                else{  
                find=false;
                 cout<<"你删除节点后的二叉树按照前序遍历为:\n";
                 bt.preorder (bt.root );
                }
                break;}
        case 9:
            {cout<<"请输入二叉树的节点数,节点数大于零\n";
            int num;
            cin>>num;

                int *a=new int[num];
                int *b=new int[num];            
              cout<<"请输入二叉树的前序遍历:\n";
              for(int i=0;i<num;i++)
              cin>>a[i];
              cout<<"请输入二叉树的中序遍历:\n";
              for(int j=0;j<num;j++)
              cin>>b[j];
                BT *t=new BT;
                t->creatpost(&t->root,a,0,num-1,b,0,num-1);
                cout<<"这是你创建的二叉树的后序遍历:\n";
              t->postorder(t->root);
            }
       }
      int goon;      
cout<<"你还想试试其它操作吗?"<<"\n"<<"若是,则输入1,否则输入0"<<endl;
      cin>>goon;
      if(goon==0) t=false;
        }
}
 

43 楼


我谁能帮我写一个关于二叉树的主程序吗?要求有选择功能!
非常感谢!!
  
 
 

作者:flairivy
专家分:30
 
 会员信息
 发短消息  
 所属BLOG  
 发表时间:2006-12-3 9:45:00    [回复]  [引用] 
1 楼  

void main()
{ BT bt;
      int choice;
      bool t=true;

    while(t)
    {
        cout<<"1.生成二叉树\n";
        cout<<"2.先序遍历\n";
             cout<<"3.中序遍历\n";
        cout<<"4.后序遍历\n"; 
            cout<<"5.层次遍历\n";
        cout<<"6.计算二叉树结点数目 \n"; 
        cout<<"7.计算二叉树高度\n"; 
        cout<<"8.删除指定元素\n";
        cout<<"9.给出二叉树的前序和中序,输出它的后序\n";
        cout<<"请选择操作"<<endl;
        cin>>choice;
       switch(choice)
        {
        case 1:{bt.CreateBT(&bt.root);
               break;}
        case 2:{    
            if (bt.root ==NULL)
               cout<<"二叉树为空,请先创建/n";
          else
            bt.preorder(bt.root);
            break;
               }
        case 3:{
            if (bt.root ==NULL)
               cout<<"二叉树为空,请先创建/n";
          else
            bt.inorder(bt.root);
            break;
               }
        case 4:{
            if (bt.root ==NULL)
               cout<<"二叉树为空,请先创建/n";
          else
            bt.postorder(bt.root);
            break;
               }
        case 5:{bt.translever(bt.root);
            break;}
        case 6:{
            bt.jiediannumber(bt.root);
            cout<<"结点数为:"<<count<<endl;
                        count=0;
            break;}
        case 7:{cout<<"高度度为"<<bt.depth(bt.root)<<endl;
            break;}
        case 8:{cout<<"你创建的二叉树按照前序遍历为:\n";
               bt.preorder (bt.root );
                cout<<"\n";
            cout<<"请输入你要删除的节点的数值"<<endl;
                int d;
                cin>>d;
                bt.Delete(&bt.root,d);
                if(find==false) cout<<"没有你要删除的节点 ";
                else{  
                find=false;
                 cout<<"你删除节点后的二叉树按照前序遍历为:\n";
                 bt.preorder (bt.root );
                }
                break;}
        case 9:
            {cout<<"请输入二叉树的节点数,节点数大于零\n";
            int num;
            cin>>num;

                int *a=new int[num];
                int *b=new int[num];            
              cout<<"请输入二叉树的前序遍历:\n";
              for(int i=0;i<num;i++)
              cin>>a[i];
              cout<<"请输入二叉树的中序遍历:\n";
              for(int j=0;j<num;j++)
              cin>>b[j];
                BT *t=new BT;
                t->creatpost(&t->root,a,0,num-1,b,0,num-1);
                cout<<"这是你创建的二叉树的后序遍历:\n";
              t->postorder(t->root);
            }
       }
      int goon;      
cout<<"你还想试试其它操作吗?"<<"\n"<<"若是,则输入1,否则输入0"<<endl;
      cin>>goon;
      if(goon==0) t=false;
        }
}
 
[b][/b]

44 楼


我也要
520penggang@163.com

45 楼

himuramars@163.com
我也要 谢谢谢

46 楼

我也想要一份,谢谢[em4]

47 楼


我也要份
UK-1987@163.com

48 楼

我也要啊  我的油箱是rnx1001@163.com

49 楼


好心人,能否也发给我一份,急用,谢谢
furui0819@sohu.com

50 楼

我也要一份
谢谢了啊
yiyezhiqiou55@yahoo.com.cn

我来回复

您尚未登录,请登录后再回复。点此登录或注册