zoukankan      html  css  js  c++  java
  • SDUST数据结构

    判断题:

     

     

     

     

     

     

     

     

     

     

    选择题:

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    函数题:

    6-1 统计二叉树叶子结点个数:

    题目:

    裁判测试程序样例:

    #include <stdio.h>
    #include <stdlib.h>
    
    typedef char ElemType;
    typedef struct BiTNode
    {
        ElemType data;
        struct BiTNode *lchild,*rchild;
    }BiTNode,*BiTree;
    
    BiTree Create();/* 细节在此不表 */
    
    int LeafCount ( BiTree T);
    
    int main()
    {
        BiTree T = Create();
    
        printf("%d
    ", LeafCount(T));
        return 0;
    }
    /* 你的代码将被嵌在这里 */

     输出样例:

    代码:

    int LeafCount ( BiTree T)
    {
        if(T==NULL)
            return 0;
        if(T->lchild == NULL && T->rchild == NULL)
            return 1;
        else
            return LeafCount(T->lchild) + LeafCount(T->rchild);
    }
    View Code

    6-2 递增的整数序列链表的插入 :

    题目:

    裁判测试程序样例:

    #include <stdio.h>
    #include <stdlib.h>
    
    typedef int ElementType;
    typedef struct Node *PtrToNode;
    struct Node {
        ElementType Data;
        PtrToNode   Next;
    };
    typedef PtrToNode List;
    
    List Read(); /* 细节在此不表 */
    void Print( List L ); /* 细节在此不表 */
    
    List Insert( List L, ElementType X );
    
    int main()
    {
        List L;
        ElementType X;
        L = Read();
        scanf("%d", &X);
        L = Insert(L, X);
        Print(L);
        return 0;
    }
    
    /* 你的代码将被嵌在这里 */

    输入样例:

    5
    1 2 4 5 6
    3

    输出样例:

    1 2 3 4 5 6 

    代码:

    /* 你的代码将被嵌在这里 */
    List Insert( List L, ElementType X )
    {
        List p,q;
        q = L;
        p = (List)malloc(sizeof(PtrToNode));
        p ->Next = NULL;
        p->Data = X;
        while(L->Next && L->Next->Data<X)
        {
            L = L->Next;
        }
        p ->Next = L->Next;
        L->Next = p;
        return q;
    }
    View Code

    编程题:

    7-1 点赞狂魔 :

    题目:

    输入样例:

    5
    bob 11 101 102 103 104 105 106 107 108 108 107 107
    peter 8 1 2 3 4 3 2 5 1
    chris 12 1 2 3 4 5 6 7 8 9 1 2 3
    john 10 8 7 6 5 4 3 2 1 7 5
    jack 9 6 7 8 9 10 11 12 13 14

    输出样例:

    jack chris john

    代码:

    #include <cstdio>
    #include <string.h>
    #include <string>
    #include <iostream>
    #include <algorithm>
    #include <cmath>
    #include <set>
    using namespace std;
    const int maxen=1010;
    struct edge{
        char name[30];
        int num;
        int sum;
    }node[maxen];
    bool cmp(edge x,edge y){
        if(x.sum==y.sum)
        return x.num<y.num;
        return x.sum>y.sum;
    }
    int main(void){
         int n,k,u,count=0;
         char a;
         memset(node,0,sizeof(0));
         scanf("%d",&n);
         for(int i=1;i<=n;++i)
         {
         set<int> st; 
         scanf("%s",node[i].name);
         scanf("%d",&k);
         node[i].num=k;
         for(int j=1;j<=k;++j)
           {
            scanf("%d",&u);
            st.insert(u);
           }
             node[i].sum=st.size();
          }
          sort(node+1,node+1+n,cmp);
          if(n==1){
          printf("%s - -
    ",node[1].name);
          }
          else if(n==2)
          {
          printf("%s %s -
    ",node[1].name,node[2].name);
          }
          else
          {
          for(int i=1;i<=3;++i){
          if(i==1)
          printf("%s",node[i].name);
          else
          printf(" %s",node[i].name);
          }
              printf("
    ");
          }
        return 0;
    }
    View Code
  • 相关阅读:
    c语言实现BMP图像转换为灰度图
    360初赛溢出题
    vim的完全卸载
    小谈截断上传漏洞
    cmd提权的一些常用命令
    渗透测试方向概览
    字符编码以及python的编码解释
    BrainFuck 以及运用(idf)
    记一次加解密通关Nazo
    360 心情杂记
  • 原文地址:https://www.cnblogs.com/3cH0-Nu1L/p/14127041.html
Copyright © 2011-2022 走看看