数据结构试验-线性表精要
实验目的和要求:
1.熟练掌握连表的实现,
2,编写出可执行的程序
内容和步骤:
1、 ? ?需求分析
程序的功能;
用户输入记录的name和索引,程序将记录加到连表里,用户输入记录的索引,可以
进行查找和删除,可在用户想要得位置插入记录。2. ? ?输入输出的要求;
主要有三项输入,为记录的名称,索引,插入的位置。名称为字符串,索引和位置为
整数。3. ? ?测试数据。
要求输入必须符合输入要求,否则显示消息。2、 ? ?概要设计
本程序所用的抽象数据类型的定义;
连表类的定义如下
连表的初始化,查找,删除,追加
原码如下
1 如果在链式线性表中加入统计功能,例如统计存储记录中姓氏的数量,请用C#完成这个功能;
namespace h
{
/// 1 如果在链式线性表中加入统计功能,例如统计存储记录中姓氏的数量,请用C#完成这个功能;
class Class1
{
static void Main(string[] args)
{
stu824 l=new stu824() ;
student A=new student ();
A._name =李玮;
A._ID =10;
A.next=null;
l.Append_stu824 (l,A);
A._name =赵龙山;
A._ID =10;
A.next=null;
l.Append_stu824 (l,A);
A._name =潘天路;
A._ID =10;
A.next=null;
l.Append_stu824 (l,A);
A=l.get_value (l,1);
string s;
char[] a=new char [10];
A._name .CopyTo(0,a,0,1);
Console.WriteLine ( {0},a[0] );
l.test_familyname (l);
}
}
class student
{ //元素定义
private int ID
private string name;
public student next;
public int _ID
{
get{return ID}
set{ID=value;}
}
public string _name
{
get{return name;}
set{name=value;}
}
public student()
{
ID=0;
name=;
next=null;
}
}
class stu824
{
student head =new student ();
student tail=new student ();
int lenth;
public stu824()
{
head.next =tail;
tail =head;
lenth=0;
}
public int get_lenth(stu824 l)
{
return l.lenth ;
}
public student get_value(stu824 l,int n)
{
student stu=new student ();
stu=l.head ;
for(int i=0;in;i++)
{
if (stu!=null)
stu=stu.next ;
}
return stu;
}
public bool Append_stu824(stu824 l,student A)
{
student stu=new student ();
stu._ID =A._824;
stu._name =A._name ;
stu.next =null;
l.tail.next=stu ;
l.tail =stu ;
l.lenth ++;
return true;
}
public bool test_familyname(stu824 l)
{//完成姓氏统计功能
student A=new student ();
char[] s=new char [10];
int [] n=new int [10];
A=l.head .next ;
int i=0
您可能关注的文档
最近下载
- 江苏省徐州市2025年中考英语真题附真题答案.docx VIP
- 高中生物生态系统的稳定性全国示范课微课金奖教案.docx VIP
- 2025至2030年中国游泳行业市场调研及未来发展趋势预测报告.docx
- 校外住宿家长知情同意书.docx VIP
- 昆山市区域银医通项目建设方案.doc VIP
- 无锡市地表水(环境)功能区划(2021-2030年).pdf VIP
- 中考真题2023年江苏省苏州市中考英语真题附答案.docx VIP
- 鲁教版五四学制七年级下数学第八章平行线的有关证明》检测题含答案初一数学试卷分析.doc VIP
- 人教版三年级下册计算题大全.docx
- 海南安装工程综合定额常用册(说明).pdf VIP
原创力文档

文档评论(0)