实验二 线性表综合实验之静态链表

一、实验目的

巩固线性表的数据结构的存储方法和相关操作,学会针对具体应用,使用线性表的相关知识来解决具体问题。

二、实验内容

建立一个有n个学生成绩的静态链表,n的大小由自己确定,实现数据的对表进行插入、删除、查找等操作。分别输出结果。

三、算法实现

#include
   
   
    
    
using namespace std;
const int MAX_SIZE=100;
struct node{
	float score;
	int next;
};
class Score_staticLink{
private:
	node score[MAX_SIZE];
	int first,avail;
public:
	Score_staticLink();
	Score_staticLink(float a[],int n);
	~Score_staticLink(){}
	float getValue(int index);
	void locate(float x);
	void insert(int index,float x);
	float _delete(int index);
	void print();
};
Score_staticLink::Score_staticLink(){
	first=0;
	score[0].next=-1;
	avail=1;
	int p=avail;
	for(int i=2;i
    
    
     
     MAX_SIZE) throw"参数非法!\n";
	first=0;
	int p=0;
	for(int i=1;i
     
     
      
      MAX_SIZE) throw"查找位置非法!\n\n";
	if(score[first].next==-1) throw"成绩为空!\n\n";
	int count=0,p=first;
	while(p!=-1&&count++
      
      
       
       MAX_SIZE) throw"插入位置非法!\n\n";
	int p=first,count=1;
	while(p!=-1&&count++
       
       
         MAX_SIZE) throw"删除位置非法!\n\n"; int p=first,count=1; while(p!=-1&&count++ 
         
       
      
      
     
     
    
    
   
   
四、运行结果


异常调试:


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值