データ構造——線形テーブル——順序記憶構造——C++実現線形テーブル


シーケンスストレージ構造C++実装編:主に線形テーブルの定義、初期化、表示、増加、削除点操作を実現した.
親力親為を覚えて、実践的にコードを書く.
main.cpp
/*************************************************************************** 
 *  @file       main.cpp 
 *  @author     MISAYAONE 
 *  @date       11  May 2017 
 *  @remark     11  May 2017  
 *  @theme      Sequence List  
 ***************************************************************************/  

#include "Linear_list.h"

#include 
using namespace std;

int main(int argc, char** argv)
{
	Seque_list L;
	Init_list(L);
	List_dispaly(L);

	Insertion(L,56,3);
	cout<

Linear_list.h
//          
#define MAXSIZE 1024
typedef struct
{
	int data[MAXSIZE]; //            
	int length;        //         
} Seque_list;

//       
bool Init_list(Seque_list &L);

//        
bool List_dispaly(Seque_list L);

//        
bool Insertion(Seque_list &L,int x,int i);

//        
bool Delete(Seque_list &L,int i);

Linear_list.cpp
#include "Linear_list.h"
#include 
using std::cin;
using std::cout;
using std::endl;

bool Init_list(Seque_list &L)  //            ,      
{
	L.length = 0;             //          
	int List_data,i = 0;
	while (cin>>List_data)
	{
		L.data[i] = List_data;
		++(L.length);
		++i;
	}
	return true;
}

bool List_dispaly(Seque_list L)
{
	cout<= MAXSIZE || L.length>=MAXSIZE-1) //      
	{
		return false;
	}
	else
	{
		if (i<0 || i>=L.length)               //                                
		{
			cout< i;j--)
			{
				L.data[j] = L.data[j-1];
			}
			L.data[i] = x;
			L.length +=1;     //             
		}
	}	
}

bool Delete(Seque_list &L,int i)
{
	if (i<0 || i>=L.length)   //      
	{
		return false;
	}
	else
	{
		for (int j = i; j