⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sy1_1.cpp

📁 一些基本的数据结构
💻 CPP
字号:
/*----------------------主函数进行线性表的插入删除和查找----------------------*/

#include "SList.h"

 void main()
  {
    Sqlist L;
    ElemType e,init,length;
    ElemType location,insert,del,found;
    Status i;
    int j;
    /*------------------------------------*/                                /*创建线性表*/
    i = InitList_Sq( &L );                                      
    printf( "InitSqlist=%d,  L.length=%d,  L.listsize=%d\n\n", i, L.length, L.listsize );
    printf("Pleae InitSqlist\n");
    printf("Please choice InitSqlist length!\n ");
    scanf("%d",&length);
    printf("Please input!\n ");
    for( j = 1; j <= length; j++ )
      {
        scanf("%d",&init);
        i = ListInsert_Sq( &L, j, init );
      }
    printf( "SqlistInsert=%d,  ElemType=", i );
    for( j = 1; j <= L.length; j++ )
    printf( "%d  ", L.base[j-1] );
    printf( "\nL.length=%d, L.listsize=%d\n\n", L.length, L.listsize ); 
  /*------------------------------------------*/
    printf("Please choice which location!\n");
    scanf("%d",&location);
    printf("Please choice the number of insert!\n");                  /*线性表的插入*/
    scanf("%d",&insert);
    ListInsert_Sq(&L,location,insert);
    for( j = 1; j <= L.length; j++ )
    printf( "%d  ", L.base[j-1] );
    printf("\nL.length=%d, L.listsize=%d\n\n",  L.length, L.listsize  );
 /*-----------------------------------------*/
    printf("Please Delete the location of number\n");
    scanf("%d",&del);
    i = ListDelete_Sq( &L, del, &e );                                /*线性表的删除*/
    printf( "\ListDelete_Sq=%d, ElemType=", i );
    for( j = 1; j <= L.length; j++ )
    printf( "%d  ", L.base[j-1] );
    printf("\nL.length=%d, L.listsize=%d\n\n",  L.length, L.listsize  );
  /*---------------------------------------*/
    printf("please input find number!\n");
    scanf("%d",&found);
    i=ListLocateElem_Sq(L,found);                                     /*线性表的查找*/
    if(i)
        printf("Find it!\n");
    else
        printf("No Find it!\n");       

 }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -