C 順序表的相關

2021-09-27 12:24:20 字數 2424 閱讀 4586

編譯器是vs 2019

交作業時的**》

#include

using

namespace std;

#define list_size 100

#define list_increase 10

struct student

;typedef student elemtype;

typedef

struct

list;

void

intilist

(list& l)

void

output

(list l)

//遍歷

cout << endl;

}void

input

(list& l)

while

(num > l.listsize)

if(l.listsize > list_size)

for(

int i =

0; i < num; i++)}

l.length++;}

cout << endl;

output

(l);

}void

insert

(list& l)

//允許前、後插入

while

(pos <= l.length -1)

//不在表尾部插入時,要後移表內資料

break

;//只後移一次就可以跳出了

} cout <<

"請輸入要插入的學生資訊(姓名、學號、年齡)"

<< endl;

cin >> l.elem[pos -1]

.name >> l.elem[pos -1]

.code >> l.elem[pos -1]

.year;

for(

int j =

0; j <

(pos -1)

; j++)}

cout <<

"表長"

<< l.length << endl;

cout << endl;

output

(l);

}void

delete_mumber

(list& l)

while

(pos < l.length)

break;}

l.length--

; cout << endl;

output

(l);

}void

find_location

(list& l)

//基於位置查詢

; cout <<

"要查詢的學生資訊為"

<< endl;

cout <<

"編號"

<<

" "<< loc <<

"\t"

<<

"姓名"

<<

" "<< l.elem[loc -1]

.name <<

"\t"

<<

"學號"

<<

" "<< l.elem[loc -1]

.code <<

"\t"

<<

"年齡"

<<

" "<< l.elem[loc -1]

.year << endl;

cout << endl;

}void

find_value

(list& l)

//基於值的查詢

while

(l.elem[i]

.code == code)

while

(i +

1== l.length)}}

intmain()

順序表的建立首先要宣告乙個結構
,這個結構用來定義每個學生資訊單元的樣子,宣告語句寫法如下

struct student 

;

這樣後面的student結構的順序表list就有了name、year和code三個屬性。

可以用l.elem[i].name = ***來寫入。

然後給student建立乙個名字?

typedef student elemtype;
這一塊**不是很懂,先記順序,後期再修改

然後定義順序表list。

typedef

struct

list;

這句語句:elemtype* elem; 似乎是為list申請乙個

c 實現順序表的相關操作

myarray.件 pragma once includeusing namespace std class myarray myarray.cpp include myarray.h 預設構造 myarray myarray 有參構造 引數 陣列容量 myarray myarray int cap...

順序表的相關操作

include include include struct arr void init arr struct arr parr,int length bool insert arr struct arr parr,int pos,int pval bool delete arr struct ar...

順序表的相關操作

順序表 靜態順序表 使用定長陣列儲存。動態順序表 使用動態開闢的陣列儲存。每一種資料結構說到底都逃不過增刪改查,相對而言順序表的相關操作比較簡單,話不多說,咱們直接上 includeusing namespace std 順序表的定義 typedef struct seqlist seqlist 順...