📄 zj.cpp
字号:
#include <stdio.h>
#include <malloc.h>
#include <iostream.h>
#include "SqList.h"
void main(){
CSqList L;
int i,choice,pos;
ElemType e;
char ch;
while(1)
{
cout<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<"$ 1: 从键盘输入10个数据,初始化一个线性表。 $"<<endl;
cout<<"$ 2: 顺序表的查找操作 $"<<endl;
cout<<"$ 3: 顺序表插入操作 $"<<endl;
cout<<"$ 4: 顺序表删除操作 $"<<endl;
cout<<"$ 5: 显示顺序表数据元素 $"<<endl;
cout<<"$ 0: 退 出 程 序 $"<<endl;
cout<<"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<endl<<"Input your choice(0,1,2,3,4,5):";
cin>>ch;
if((ch<'0')||(ch>'6'))
break;
choice=ch-'0';
switch(choice)
{
case 1:
for(i=1;i<=10;i++)
{
cout<<"请输入第 "<<i<<" 个数据元素";
cin>>e;
L.ListInsert(L.List,i,e);
}
break;
case 2:
cout<<"请输入待查数据元素值:";
cin>>e;
if(TRUE==L.LocateElem(L.List,e,pos))
cout<<"第"<<pos<<"个数据元素值等于"<<e<<endl;
else cout<<"找不到";
break;
case 3:
cout<<"请输入待插入位置:";
cin>>pos;
cout<<"请输入待插入的数据元素值:";
cin>>e;
L.ListInsert(L.List,pos,e);
L.ListDisplay(L.List);
break;
case 4:
cout<<"请输入待删除的数据元素的位置:";
cin>>pos;
if(OK==L.ListDelete(L.List,pos,e))
cout<<"被删除的数据元素值为:"<<e<<endl;
else
cout<<"输入待删除的数据元素的位置不合理!";
break;
case 5:
L.ListDisplay(L.List);
break;
default:
;
}
if(choice==0)
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -