zoukankan      html  css  js  c++  java
  • 《软件工程》开课总结

    新学期 新起点。

    上个学期学习了C、Java等语言,学习了数据结构、uml,web等课程,会写一些简单的算法程序例如排序、最短路径等

    #include<stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    typedef struct BSTNode{
    
            int data;
    
            struct BSTNode *lchild,*rchild;
    
    }BSTNode,*BSTree;
    BSTree InsertBST(BSTree T,int data);
    BSTree CreatBST(BSTree T);
    bool SearchBST(BSTree T,int key);
    void DeleteBST(BSTree T,int key);
    void PrintBST(BSTree T);
    bool DeleteBST(BSTree *T, int key);
    bool Delete(BSTree *T);
    void homePage();
    void homePage1();
    int main(){
        BSTree T;
        T=NULL;
        int key,key2;
        int num;
        bool n;
        printf("\t\t\t\t\t****************");
        printf("\n\n\t\t\t\t\t1.创建一棵二叉树");
          printf("\n\t\t\t\t\t2.结束本程序");
          printf("\n\n\t\t\t\t\t****************\n");
          printf("请输入操作:");
          scanf("%d",&num);
          switch(num)
          {
          case 1:homePage();printf("请输入数据(输0停止):\n");T=CreatBST(T); printf("中序遍历二叉树:\n");PrintBST(T);printf("\n");break;
          case 2:exit(0);
          }
          for(int i=0;i>=0;i++)
          {
          homePage1();
          printf("请输入操作:");
           scanf("%d",&num);
           switch(num){
               case 1:do
                      {
                      homePage();
                      printf("请输入要查找的数据:\n");
                      scanf("%d",&key);
                      n=SearchBST(T,key);
                      }while(!n);break;
               case 2:homePage();
                      printf("请插入数据:\n");
                      scanf("%d",&key2);
                      InsertBST(T,key2);
                       printf("中序显示:\n");
                      PrintBST(T);
                      break;
              case 3: homePage();
                      printf("请输入要删除的数据:\n");
                      scanf("%d",&key);
                      DeleteBST(&T,key);
                      printf("中序显示:\n");
                      PrintBST(T);
                      printf("\n");break;
              case 4: exit(0);
           }
    
          }
        return 0;
    }
    void homePage()
    {
        static char operateValue;
        system("cls");
    }
    void homePage1()
    {
          printf("\n\t\t\t\t\t********请选择你要对这棵二叉树所做的操作********");
          printf("\n\n\t\t\t\t\t***    1......查找你想要寻找的节点           ***");
          printf("\n\t\t\t\t\t***    2......插入你想要插入的节点           ***");
          printf("\n\t\t\t\t\t***    3......删除你想要删除的节点           ***");
          printf("\n\t\t\t\t\t***    4......结束对这棵二叉树的操作         ***");
          printf("\n\n\t\t\t\t\t************************************************\n");
    
    }
    BSTree InsertBST(BSTree T,int data){
           BSTree s;
           if(!T){
                 s=(BSTNode *)malloc(sizeof(BSTree));
                 s->data=data;
                 s->lchild=NULL;
                 s->rchild=NULL;
                 return s;
           }
           else if(T->data<data){
                 T->rchild=InsertBST(T->rchild,data);
           }
           else if(T->data>data){
                 T->lchild=InsertBST(T->lchild,data);
           }
           return T;
    
    }
    
    BSTree CreatBST(BSTree T){
          int data;
          scanf("%d",&data);
          while(data!=0)
          {
              T=InsertBST(T,data);
              scanf("%d",&data);
          }
          return T;
    }
    
    bool SearchBST(BSTree T,int key){
         if(!T){
            printf("未找到该数据,请重新输入!\n");
            return false;
    
         }
        else if(T->data==key){
    
            printf("成功查找到数据:%d\n",T->data);
            return true;
        }
    
        else if(T->data>key){
          SearchBST(T->lchild,key);
        }
        else if(T->data<key){
          SearchBST(T->rchild,key);
        }
    }
    void PrintBST(BSTree T){
    
             if (!T)
              return;
             PrintBST(T->lchild);
             printf("%d ", T->data);
             PrintBST(T->rchild);
    }
    
    /*
     * 在以*T为根结点的树中,删除与key相同的结点。
     * 如果没有此结点返回FALSE。
     */
    bool DeleteBST(BSTree *T, int key){
        if (!*T)        //空树。查无此结点。
            return false;
        else if (key == (*T)->data)
        {
            Delete(T);
            return true;
        }
        else if (key < (*T)->data)
        {
            return DeleteBST(&((*T)->lchild), key);
        }
        else
        {
            return DeleteBST(&((*T)->rchild), key);
        }
    }
    
    /*
     * 删除*T指向的结点
     */
    bool Delete(BSTree *T)
    {
        BSTree L;
    
        //*T既没有左孩子,又没有右孩子,为叶子结点
        if (!(*T)->lchild && !(*T)->rchild)
            *T = NULL;
        //*T只有右孩子
        else if (!(*T)->lchild)
            *T = (*T)->rchild;
        //*T只有左孩子
        else if (!(*T)->rchild)
            *T = (*T)->lchild;
        //*T既有左孩子,又有右孩子
        else
        {
            L = (*T)->lchild;//L指向被删除结点的左子树
    
            //寻找L的最右孩子
            while (L->rchild)
                L = L->rchild;
            //把*T的右子树接到左子树最右孩子的右子树上。
            L->rchild = (*T)->rchild;
            //*T的左子树直接作为*T父结点的子树
            *T = (*T)->lchild;
        }
        return true;
    }
    二叉树

    在uml课程中,学习了几种图的绘制,对制作软件前的准备流程,以及软件建模有了一定了解;在java web学习中,学习了crud等操作,利用mysql数据库,能够制作一个最基本的系统。

    期望:

    在下学期的学习中,我将学习php语言及C++语言,学习使用matlab工具完成建模,了解数据库原理及计算机网络,更深一步学习web开发、安卓开发等,我希望能够通过本学期的学期,在学期末,具有能完全独立地完成任务的能力,以及在开发过程中学会与团队成员间的配合。

  • 相关阅读:
    HTML元素解释
    Java命名规范
    HDU 1058 Humble Numbers(DP,数)
    HDU 2845 Beans(DP,最大不连续和)
    HDU 2830 Matrix Swapping II (DP,最大全1矩阵)
    HDU 2870 Largest Submatrix(DP)
    HDU 1421 搬寝室(DP)
    HDU 2844 Coins (组合背包)
    HDU 2577 How to Type(模拟)
    HDU 2159 FATE(二维完全背包)
  • 原文地址:https://www.cnblogs.com/Arisf/p/14468440.html
Copyright © 2011-2022 走看看