C语言链表功能实现 下载本文

#include #define MaxSize 10 #define error 0

typedef int ElemType; typedef struct{

ElemType elem[MaxSize]; int last; }SeqList;

void Input(SeqList *L);//Input the list void Output(SeqList L);//Output the list void Search(SeqList L);//Search element void Insert(SeqList *L); void Delete(SeqList *L); void Sort(SeqList *L);

void bubblesort(SeqList *L); void selectsort(SeqList *L); void Function(); int main(){

int i,flag=1,k; ElemType e; SeqList L; L.last=0; Function();

printf(\ scanf(\ while(flag){ switch(k){ case 0:{ flag=0; break; }

case 1:{

Input(&L); break; }

case 2:{

Output(L); break; }

case 3:{

Insert(&L); break; }

case 4:{

Search(L); break; }

case 5:{

Delete(&L); break; }

case 6:{

bubblesort(&L); break; }

case 7:{

selectsort(&L); break; }

default :{

printf(\ break; } }

if(flag){

printf(\ scanf(\

}

}

return 0; }

void Input(SeqList *L){ int i,n;

printf(\ scanf(\ while(n>MaxSize){

printf(\ scanf(\ }

printf(\ for(i=0;i

scanf(\ L->last++; } }

void Output(SeqList L){

int i;

printf(\

for(i=0;i<(L.last>MaxSize?MaxSize:L.last);i++){ printf(\ }

printf(\}

void Search(SeqList L){ int i,flag=1; ElemType e;

printf(\ scanf(\ while(flag){

for(i=0;i

printf(\ flag=0; break; } }

if(i==L.last){

printf(\ scanf(\ }

} }

void Insert(SeqList *L){

int i,m,n,tab=0;//m represent the number inserted and n is location. if(L->last==MaxSize){

printf(\ int k=0,flag=0; scanf(\ while(k!=1||k!=2){

printf(\ scanf(\ }

switch(k){ case 1:{

printf(\input m(the number inserted) and n(the location)!\\n\

scanf(\ tab=1;