C Language "sequential table" sequence table initialization, head plug, tail plug, head Delete, tail delete, delete and delete, all deleted

Source: Internet
Author: User

#define  _CRT_SECURE_NO_WARNINGS 1#include<stdio.h> #include <assert.h> #include <stdlib.h > #include <string.h> #define  max_size 5typedef int datatype;typedef struct  seqlist{    size_t size;    datatype array[max_size];} Seqlist;//void initseqlist (SEQLIST*&NBSP;PSEQ)//{//    assert (PSEQ);//     memset (pseq->size, 0, sizeof (DataType) *max_size);//    pseq-> Size = 0;//}//void pushback (seqlist* pseq, datatype x)//{//     assert (PSEQ);//    if  (pseq->size >= max_size)//     {//        printf ("The order table is full and cannot be inserted!") ");//        return;//    }//     pseq->array[pseq->size++] = x;//&Nbsp;   pseq->size++;//}//void popback (SEQLIST*&NBSP;PSEQ)//{//     ASSERT (PSEQ);//    if  (pseq->size <= 0)//    {//         printf ("The Order table is empty and cannot be deleted!") ");//        return;//    }//     pseq->size--;//}//void pushfront (seqlist* pseq, datatype x)//{//     assert (PSEQ);//    int begin = pseq->size - 1;//     int i = 0;//    if  (pseq->size >=  max_size)//    {//        printf ("The order table is full and cannot be inserted!") ");//        return;//    }//     for  (i = begin; i >= 0; i--)//    {//        pseq->array[begin +  1] = pseq->array[begin];//    }//    pseq->array [0] = x;//    pseq->size++;//}////void popfront (SEQLIST*&NBSP;PSEQ)//{//     assert (PSEQ);//    int begin = 1;//     if  (pseq->size <= 0)//    {//         printf ("The Order table is empty and cannot be deleted!") ");//        return;//    }//     for  (begin = 1; begin < pseq->size; begin ++)//     {//        pseq->array[begin -1] =  pseq->array[begin];//    }//    pseq->size--;//}Void insert (seqlist* pseq, size_t pos, datatype x)//{//     assert (PSEQ);//    int begin = pseq->size;//     if  (pseq->size >= max_size)//    {//         printf ("The order table is full and cannot be inserted!") ");//        return 0;//    }//     for  (;  begin > pos;begin--)//    {//         pSeq->array[begin] = pSeq->array[begin-1];//     }//    pseq->array[pos] = x;//    pseq->size++;/ /}//int find (seqlist* pseq,datatype x)//{//    int i = 0;//     for  (;  i < pseq->size; i++)//    {//        if  (pseq->array[i] == x)//         {//             return i;//        }//    }     return -1;//}//void erase (Seqlist* pseq, size_t pos)//{//     assert (PSEQ);//    int begin = 0;//     if  (pseq->size <= 0)//    {//         printf ("The Order table is empty and cannot be deleted!") ");//        return;//    }//     assert (pos < pseq->size);////    for  (; begin <  pseq->size; ++begin)//    {//        pseq->array[begin - 1] = pseq->array[begin];//    }//     pseq->size--;//}//int remove (seqlist* pseq, datatype x)//{//     int pos;//    assert (PSEQ);////    pos  = find (pseq, 0, x);//    if  (pos != -1)//     {//        erase (Pseq, pos);//     }//    return pos;//}//void removeall (Seqlist* pseq, datatype &NBSP;X)//{//    int count = 0;//    int begin  = 0;//    assert (PSEQ);////    for  (; begin  < pseq->size; ++begin)//    {//         if  (pseq->array[BEGIN]&NBSP;==&NBSP;X)//        {//             ++count;//        }//         else//        {//             pseq->array[begin - count]  = pSeq->array[begin];//        }//     }////    pseq->size -= count;//}void printseqlist (SeqList*  PSEQ) {    int i = 0;    assert (PSEQ);     for  (;  i < pseq->size; ++i)     {         printf ("%d ",  pseq->array[i]);    }     printf ("\ n");}


C Language "sequential table" sequence table initialization, head plug, tail plug, head Delete, tail delete, delete and delete, all deleted

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.