資料結構實驗一(鍊錶)

2021-08-19 10:09:19 字數 1077 閱讀 7435

1. seqlist.h

#ifndef seqlist_h

#define seqlist_h

const int maxsize=10;

class seqlist

seqlist(int a,int n);

~seqlist(){}

void insert(int i,int x);

int delete(int i);

int locate(int x);

void printlist();

private:

int data[maxsize];

int length;

};#endif

2. seqlist.cpp

#include

using namespace std;

#include "seqlist.h"

seqlist::seqlist(int a,int n)

void seqlist::insert(int i,int x)

int seqlist::delete (int i)

int seqlist::locate(int x)

void seqlist::printlist ()

3. seqlist_main.cpp

#include

using namespace std;

#include "seqlist.h"

void main()

;seqlist l(r,5);

cout<<"執行插入操作前資料為:"<

l.printlist ();

trycatch(char*s)

cout<<"執行插入操作後資料為:"<

l.printlist ();

cout<<"值為3的元素位置為:";

cout<

cout<<"執行刪除第乙個元素操作,刪除前資料為:"<

l.printlist ();

trycatch(char*s)

cout<<"刪除後資料為:"<

l.printlist ();

}

資料結構實驗之鍊表一 順序建立鍊錶

time limit 1000ms memory limit 65536k 輸入n個整數,按照輸入的順序建立單鏈表儲存,並遍歷所建立的單鏈表,輸出這些資料。第一行輸入整數的個數n 第二行依次輸入每個整數。輸出這組整數。8 12 56 4 6 55 15 33 62 12 56 4 6 55 15 3...

資料結構實驗之鍊表一 順序建立鍊錶

好久都沒有寫部落格了,這次做乙個簡單的鍊錶題,找找感覺。輸入n個整數,按照輸入的順序建立單鏈表儲存,並遍歷所建立的單鏈表,輸出這些資料。第一行輸入整數的個數n 第二行依次輸入每個整數。輸出這組整數。8 12 56 4 6 55 15 33 62 12 56 4 6 55 15 33 62 不得使用陣...

資料結構實驗之鍊表一 順序建立鍊錶

time limit 1000ms memory limit 65536k 有疑問?點這裡 輸入n個整數,按照輸入的順序建立單鏈表儲存,並遍歷所建立的單鏈表,輸出這些資料。第一行輸入整數的個數n 第二行依次輸入每個整數。輸出這組整數。8 12 56 4 6 55 15 33 62 12 56 4 6...