zoukankan      html  css  js  c++  java
  • 第八周 技术博客发表 数据结构

    #include "stdafx.h"

    #include "stdio.h"
    #include "stdlib.h"

    typedef int DataType;

    typedef struct Space
    {
     DataType data;
     Space* next;
    }Space;

    typedef struct Queue
    {
     Space* base;
     Space* top;
     int length;
     
    }Queue;

    Queue* initQ()
    {
     Queue *myQ;
     myQ=(Queue *)malloc(sizeof(Queue));
     myQ->length;
     myQ->base=(Space *)malloc(sizeof(Space));
     myQ->base->next=NULL;
     myQ->top=myQ->base;
     return myQ;
    }

    void insQ(Queue* myQ, DataType data)
    {
     Space *temp=(Space *)malloc(sizeof(Space));
     temp->next=NULL;
     temp->data=data;
     myQ->top->next=temp;
     myQ->top->next=myQ->top->next->next;
     myQ->length++;
    }

    void remQ(Queue* myQ)
    {
     if(myQ->length==0)
      printf("the queue is empty");
     Space* temp=myQ->base->next;
     myQ->base->next=myQ->base->next->next;
     free(temp);
     myQ->length--;
    }

    void getTop(Queue* myQ)
    {
     printf("%d  ",myQ->base->next->data );
    }

    int main(int argc, char const *argv[])
    {
     /* code */
     return 0;
    }

  • 相关阅读:
    Java内置包装类
    for循环思路题
    常用函数
    函数
    冒泡排序
    数组的运用
    for循环中有意思的练习题。
    for循环
    运算中容易出现的错误
    分支的运用
  • 原文地址:https://www.cnblogs.com/youu/p/5444259.html
Copyright © 2011-2022 走看看