求线性表的C语言程序 20
主函数要有线性表的建立及四个子函数的调用。四个子函数分别为线性表的插入查找删除修改。急用!!!...
主函数要有线性表的建立及四个子函数的调用。
四个子函数分别为线性表的插入 查找 删除 修改。
急用!!! 展开
四个子函数分别为线性表的插入 查找 删除 修改。
急用!!! 展开
2个回答
展开全部
第一个文件commom.h
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
第二个文件seqlist.h
#define ElemType int
#define MAXSIZE 100 /*此处的宏定义常量表示线性表可能达到的最大长度*/
typedef struct
{
ElemType elem[MAXSIZE]; /*线性表占用的数组空间*/
int last; /*记录线性表中最后一个元素在数组elem[ ]中的位置(下标值),空表置为-1*/
}SeqList;
第三个文件locate.cpp
#include "common.h"
#include "seqlist.h"
int Locate(SeqList L, ElemType e)
{
int i=0; /*i为扫描计数器,初值为0,即从第一个元素开始比较*/
while ((i<=L.last)&&(L.elem[i]!=e)) /*顺序扫描表,直到找到值为key的元素, 或扫描到表尾而没找到*/
i++;
if (i<=L.last)
return(i+1); /*若找到值为e的元素,则返回其序号*/
else
return(-1); /*若没找到,则返回空序号*/
}
void main()
{
SeqList l;
int p,q,r;
int i;
printf("请输入线性表的长度:");
scanf("%d",&r);
l.last = r-1;
printf("请输入线性表的各元素值:\n");
for(i=0; i<=l.last; i++)
{
scanf("%d",&l.elem[i]);
}
printf("请输入要查找的元素值:\n");
scanf("%d",&q);
p=Locate(l,q);
if(p == -1)
printf("在此线性表中没有该元素!\n");
else
printf("该元素在线性表中的位置为:%d\n",p);
}
第四个文件InsList.cpp
#include "common.h"
#include "seqlist.h"
/*在顺序表L中第i个数据元素之前插入一个元素e。 插入前表长n=L->last+1,
i的合法取值范围是 1≤i≤L->last+2 */
int InsList(SeqList *L,int i,ElemType e)
{
int k;
if((i<1) || (i>L->last+2)) /*首先判断插入位置是否合法*/
{
printf("插入位置i值不合法");
return(ERROR);
}
if(L->last>= MAXSIZE-1)
{
printf("表已满无法插入");
return(ERROR);
}
for(k=L->last;k>=i-1;k--) /*为插入元素而移动位置*/
L->elem[k+1]=L->elem[k];
L->elem[i-1]=e; /*在C语言数组中,第i个元素的下标为i-1*/
L->last++;
return(OK);
}
void main()
{
SeqList *l;
int p,q,r;
int i;
l=(SeqList*)malloc(sizeof(SeqList));
printf("请输入线性表的长度:");
scanf("%d",&r);
l->last = r-1;
printf("请输入线性表的各元素值:\n");
for(i=0; i<=l->last; i++)
{
scanf("%d",&l->elem[i]);
}
printf("请输入要插入的位置:\n");
scanf("%d",&p);
printf("请输入要插入的元素值:\n");
scanf("%d",&q);
InsList(l,p,q);
for(i=0; i<=l->last; i++)
{
printf("%d ",l->elem[i]);
}
}
第五个文件DelList.cpp
#include "common.h"
#include "seqlist.h"
int DelList(SeqList *L,int i,ElemType *e)
/*在顺序表L中删除第i个数据元素,并用指针参数e返回其值。i的合法取值为1≤i≤L.last+1 */
{
int k;
if((i<1)||(i>L->last+1))
{
printf("删除位置不合法!");
return(ERROR);
}
*e = L->elem[i-1]; /* 将删除的元素存放到e所指向的变量中*/
for(k=i; i<=L->last; k++)
L->elem[k-1] = L->elem[k]; /*将后面的元素依次前移*/
L->last--;
return(OK);
}
void main()
{
SeqList *l;
int p,r;
int *q;
int i;
l = (SeqList*)malloc(sizeof(SeqList));
q = (int*)malloc(sizeof(int));
printf("请输入线性表的长度:");
scanf("%d",&r);
l->last = r-1;
printf("请输入线性表的各元素值:\n");
for(i=0; i<=l->last; i++)
{
scanf("%d",&l->elem[i]);
}
printf("请输入要删除的元素位置:\n");
scanf("%d",&p);
DelList(l,p,q);
printf("删除的元素值为:%d\n",*q);
}
第六个文件merge.cpp
#include "common.h"
#include "seqlist.h"
void merge(SeqList *LA, SeqList *LB, SeqList *LC)
{
int i,j,k;
i=0;j=0;k=0;
while(i<=LA->last&&j<=LB->last)
if(LA->elem[i]<=LB->elem[j])
{
LC->elem[k]= LA->elem[i];
i++;
k++;
}
else
{
LC->elem[k]=LB->elem[j];
j++;
k++;
}
while(i<=LA->last) /*当表LA有剩余元素时,则将表LA余下的元素赋给表LC*/
{
LC->elem[k]= LA->elem[i];
i++;
k++;
}
while(j<=LB->last) /*当表LB有剩余元素时,则将表LB余下的元素赋给表LC*/
{
LC->elem[k]= LB->elem[j];
j++;
k++;
}
LC->last=LA->last+LB->last+1;
}
void main()
{
SeqList *la,*lb,*lc;
int r;
int i;
la=(SeqList*)malloc(sizeof(SeqList));
printf("请输入线性表A的长度:");
scanf("%d",&r);
la->last = r-1;
printf("请输入线性表A的各元素值:\n");
for(i=0; i<=la->last; i++)
{
scanf("%d",&la->elem[i]);
}
lb=(SeqList*)malloc(sizeof(SeqList));
printf("请输入线性表B的长度:");
scanf("%d",&r);
lb->last = r-1;
printf("请输入线性表B的各元素值:\n");
for(i=0; i<=lb->last; i++)
{
scanf("%d",&lb->elem[i]);
}
lc=(SeqList*)malloc(sizeof(SeqList));
merge(la,lb,lc);
printf("合并后线性表C中的元素为:\n");
for(i=0; i<=lc->last; i++)
{
printf("%d ",lc->elem[i]);
}
}
包含了线性表插入,查找,删除,合并运算。
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
第二个文件seqlist.h
#define ElemType int
#define MAXSIZE 100 /*此处的宏定义常量表示线性表可能达到的最大长度*/
typedef struct
{
ElemType elem[MAXSIZE]; /*线性表占用的数组空间*/
int last; /*记录线性表中最后一个元素在数组elem[ ]中的位置(下标值),空表置为-1*/
}SeqList;
第三个文件locate.cpp
#include "common.h"
#include "seqlist.h"
int Locate(SeqList L, ElemType e)
{
int i=0; /*i为扫描计数器,初值为0,即从第一个元素开始比较*/
while ((i<=L.last)&&(L.elem[i]!=e)) /*顺序扫描表,直到找到值为key的元素, 或扫描到表尾而没找到*/
i++;
if (i<=L.last)
return(i+1); /*若找到值为e的元素,则返回其序号*/
else
return(-1); /*若没找到,则返回空序号*/
}
void main()
{
SeqList l;
int p,q,r;
int i;
printf("请输入线性表的长度:");
scanf("%d",&r);
l.last = r-1;
printf("请输入线性表的各元素值:\n");
for(i=0; i<=l.last; i++)
{
scanf("%d",&l.elem[i]);
}
printf("请输入要查找的元素值:\n");
scanf("%d",&q);
p=Locate(l,q);
if(p == -1)
printf("在此线性表中没有该元素!\n");
else
printf("该元素在线性表中的位置为:%d\n",p);
}
第四个文件InsList.cpp
#include "common.h"
#include "seqlist.h"
/*在顺序表L中第i个数据元素之前插入一个元素e。 插入前表长n=L->last+1,
i的合法取值范围是 1≤i≤L->last+2 */
int InsList(SeqList *L,int i,ElemType e)
{
int k;
if((i<1) || (i>L->last+2)) /*首先判断插入位置是否合法*/
{
printf("插入位置i值不合法");
return(ERROR);
}
if(L->last>= MAXSIZE-1)
{
printf("表已满无法插入");
return(ERROR);
}
for(k=L->last;k>=i-1;k--) /*为插入元素而移动位置*/
L->elem[k+1]=L->elem[k];
L->elem[i-1]=e; /*在C语言数组中,第i个元素的下标为i-1*/
L->last++;
return(OK);
}
void main()
{
SeqList *l;
int p,q,r;
int i;
l=(SeqList*)malloc(sizeof(SeqList));
printf("请输入线性表的长度:");
scanf("%d",&r);
l->last = r-1;
printf("请输入线性表的各元素值:\n");
for(i=0; i<=l->last; i++)
{
scanf("%d",&l->elem[i]);
}
printf("请输入要插入的位置:\n");
scanf("%d",&p);
printf("请输入要插入的元素值:\n");
scanf("%d",&q);
InsList(l,p,q);
for(i=0; i<=l->last; i++)
{
printf("%d ",l->elem[i]);
}
}
第五个文件DelList.cpp
#include "common.h"
#include "seqlist.h"
int DelList(SeqList *L,int i,ElemType *e)
/*在顺序表L中删除第i个数据元素,并用指针参数e返回其值。i的合法取值为1≤i≤L.last+1 */
{
int k;
if((i<1)||(i>L->last+1))
{
printf("删除位置不合法!");
return(ERROR);
}
*e = L->elem[i-1]; /* 将删除的元素存放到e所指向的变量中*/
for(k=i; i<=L->last; k++)
L->elem[k-1] = L->elem[k]; /*将后面的元素依次前移*/
L->last--;
return(OK);
}
void main()
{
SeqList *l;
int p,r;
int *q;
int i;
l = (SeqList*)malloc(sizeof(SeqList));
q = (int*)malloc(sizeof(int));
printf("请输入线性表的长度:");
scanf("%d",&r);
l->last = r-1;
printf("请输入线性表的各元素值:\n");
for(i=0; i<=l->last; i++)
{
scanf("%d",&l->elem[i]);
}
printf("请输入要删除的元素位置:\n");
scanf("%d",&p);
DelList(l,p,q);
printf("删除的元素值为:%d\n",*q);
}
第六个文件merge.cpp
#include "common.h"
#include "seqlist.h"
void merge(SeqList *LA, SeqList *LB, SeqList *LC)
{
int i,j,k;
i=0;j=0;k=0;
while(i<=LA->last&&j<=LB->last)
if(LA->elem[i]<=LB->elem[j])
{
LC->elem[k]= LA->elem[i];
i++;
k++;
}
else
{
LC->elem[k]=LB->elem[j];
j++;
k++;
}
while(i<=LA->last) /*当表LA有剩余元素时,则将表LA余下的元素赋给表LC*/
{
LC->elem[k]= LA->elem[i];
i++;
k++;
}
while(j<=LB->last) /*当表LB有剩余元素时,则将表LB余下的元素赋给表LC*/
{
LC->elem[k]= LB->elem[j];
j++;
k++;
}
LC->last=LA->last+LB->last+1;
}
void main()
{
SeqList *la,*lb,*lc;
int r;
int i;
la=(SeqList*)malloc(sizeof(SeqList));
printf("请输入线性表A的长度:");
scanf("%d",&r);
la->last = r-1;
printf("请输入线性表A的各元素值:\n");
for(i=0; i<=la->last; i++)
{
scanf("%d",&la->elem[i]);
}
lb=(SeqList*)malloc(sizeof(SeqList));
printf("请输入线性表B的长度:");
scanf("%d",&r);
lb->last = r-1;
printf("请输入线性表B的各元素值:\n");
for(i=0; i<=lb->last; i++)
{
scanf("%d",&lb->elem[i]);
}
lc=(SeqList*)malloc(sizeof(SeqList));
merge(la,lb,lc);
printf("合并后线性表C中的元素为:\n");
for(i=0; i<=lc->last; i++)
{
printf("%d ",lc->elem[i]);
}
}
包含了线性表插入,查找,删除,合并运算。
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
展开全部
这是我无聊写下的一个完整的线性表,我也懒得剔除多余的了!是一个储存学生成绩的表,里面包含增删改查4个功能,希望采纳!!!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace linear
{
interface ILinarList<T>
{
void InsertNode(T a,int i);
void DeleteNode(int i);
T SearchNode(int i);
T SearchNode(T value);
int GetLength();
void Clear();
bool IsEmpty();
}
public class SeqList<T> :ILinarList<T>
{
private int maxsize;
private T[] data;
private int length;
public int Length
{
get
{
return length;
}
}
public int Maxsize
{
get
{
return maxsize;
}
set
{
maxsize = value;
}
}
public SeqList(int size)
{
maxsize = size;
data = new T[maxsize];
length = 0;
}
public void InsertNode(T a)
{
if (IsFull())
{
Console.WriteLine("List is null");
return;
}
data[length] = a;
length++;
}
public void InsertNode(T a, int i)
{
if (IsFull())
{
Console.WriteLine("List is full");
return;
}
if (i < 1 || i > length + 1)
{
Console.WriteLine("Postition is error!");
return;
}
else
{
for (int j = length - 1; j >= i; j--)
{
data[j + 1] = data[j];
}
data[i - 1] = a;
}
length++;
}
public void DeleteNode(int i)
{
if (IsEmpty())
{
Console.WriteLine("list is empty");
return;
}
if (i < 1 || i > length)
{
Console.WriteLine("Position is error!");
return;
}
for (int j = i; j < length; j++)
{
data[j - 1] = data[j];
}
length++;
}
public T SearchNode(int i)
{
if (IsEmpty() || (i < 1) || (i > length))
{
Console.WriteLine("list is empty or Positon is error!");
return default(T);
}
return data[i - 1];
}
public T SearchNode(T value)
{
if (IsEmpty())
{
Console.WriteLine("list is empty!");
return default(T);
}
int i = 0;
for (i = 0; i < length; i++)
{
if (data[i].ToString().Contains(value.ToString()))
{
break;
}
}
if (i >= length)
{
return default(T);
}
return data[i];
}
public int GetLength()
{
return length;
}
public void Clear()
{
length = 0;
}
public bool IsEmpty()
{
if (length == 0)
{
return true;
}
else
{
return false;
}
}
public bool IsFull()
{
if (length == maxsize)
{
return true;
}
else
{
return false;
}
}
}
class StuNode
{
private string stu_no;
private string stu_name;
private int stu_score;
public string Stu_no
{
get {
return stu_no;
}
set {
stu_no = value;
}
}
public string Stu_name
{
get {
return stu_name;
}
set {
Stu_name = value;
}
}
public int Stu_score
{
get {
return stu_score;
}
set {
stu_score = value;
}
}
public StuNode(string stu_no, string stu_name, int stu_score)
{
this.stu_no = stu_no;
this.stu_name = stu_name;
this.stu_score = stu_score;
}
public override string ToString()
{
return stu_no + Stu_name;
}
}
class SeqListApp
{
public static void Main()
{
ILinarList<StuNode> stuList = null;
Console.Write("请选择储存结构的类型:1.顺序表2.单连表3.双连表4.循环表:");
char seleflag = Convert.ToChar(Console.ReadLine());
switch (seleflag)
{
case '1':
Console.Write("请输入学生数:");
int maxsize = Convert.ToInt32(Console.ReadLine());
stuList = new SeqList<StuNode>(maxsize);
break;
}
while (true)
{
Console.WriteLine("请输入操作选项:");
Console.WriteLine("1.添加学生成绩");
Console.WriteLine("2.删除学生成绩");
Console.WriteLine("3.按姓名查询学生成绩");
Console.WriteLine("4.按学号查询学生成绩");
Console.WriteLine("5.按升序显示学生的成绩");
Console.WriteLine("6.按降序显示学生的成绩");
Console.WriteLine("7.退出");
seleflag = Convert.ToChar(Console.ReadLine());
switch (seleflag)
{
case '1':
{
char flag;
do
{
string stu_no;
string stu_name;
int stu_score;
Console.Write("请输入学号:");
stu_no = Console.ReadLine();
Console.Write("请输入姓名:");
stu_name =Console.ReadLine();
Console .Write("请输入学生成绩:");
stu_score = Convert.ToInt32(Console.ReadLine());
StuNode newNode = new StuNode(stu_no,stu_name,stu_score);
if(stuList.GetLength() == 0)
{
stuList.InsertNode(newNode,1);
}
else if (newNode.Stu_score>(stuList.SearchNode(stuList.GetLength()).Stu_score))
{
stuList.InsertNode(newNode,stuList.GetLength()+1);
}
else
{
for(int i = 1;i<=stuList.GetLength();i++)
{
if(newNode.Stu_score<=stuList.SearchNode(i).Stu_score)
{
stuList.InsertNode(newNode, i);
break;
}
}
}
Console.Write("还有学生成绩输入吗(Y/N):");
flag = Convert.ToChar(Console.ReadLine());
}
while(flag == 'Y');
break;
}
case '2':
{
StuNode temp;
Console.Write("请出输入要出删除学生的学号:");
string stu_no = Console.ReadLine();
for(int i = 1; i <= stuList.GetLength();i++)
{
temp = stuList.SearchNode(i);
if (temp.Stu_no == stu_no)
{
stuList.DeleteNode(i);
break;
}
}
break;
}
case '3':
{
StuNode temp;
Console.Write("请输入要查询学生的姓名:");
string stu_name = Console.ReadLine();
for (int i = 1; i <= stuList.GetLength(); i++)
{
temp = stuList.SearchNode(i);
if (temp.Stu_name == stu_name)
{
Console.WriteLine("{0}的成绩是:{1}",stu_name,temp.Stu_score);
break;
}
}
break;
}
case '4':
{
StuNode temp;
Console.Write("请输入要查询学生的学号:");
string stu_no = Console.ReadLine();
for (int i = 1; i <= stuList.GetLength(); i++)
{
temp = stuList.SearchNode(i);
if (temp.Stu_no == stu_no)
{
Console.WriteLine("学号为{0}的成绩是:{1}",stu_no,temp.Stu_score);
break;
}
}
break;
}
case '5':
{
StuNode temp = null;
for (int i = 1; i <= stuList.GetLength(); i++)
{
temp = stuList.SearchNode(i);
Console.WriteLine("{0}\t{1}\t{2}",temp.Stu_no,temp.Stu_name,temp.Stu_score);
}
break;
}
case '6':
{
StuNode temp = null;
for (int i = stuList.GetLength(); i >= 1; i--)
{
temp = stuList.SearchNode(i);
Console.WriteLine("{0}\t{1}\t{2}", temp.Stu_no, temp.Stu_name, temp.Stu_score);
}
break;
}
case '7':
{
return;
}
}
Console.Write("按任意键继续。。。");
Console.ReadLine();
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace linear
{
interface ILinarList<T>
{
void InsertNode(T a,int i);
void DeleteNode(int i);
T SearchNode(int i);
T SearchNode(T value);
int GetLength();
void Clear();
bool IsEmpty();
}
public class SeqList<T> :ILinarList<T>
{
private int maxsize;
private T[] data;
private int length;
public int Length
{
get
{
return length;
}
}
public int Maxsize
{
get
{
return maxsize;
}
set
{
maxsize = value;
}
}
public SeqList(int size)
{
maxsize = size;
data = new T[maxsize];
length = 0;
}
public void InsertNode(T a)
{
if (IsFull())
{
Console.WriteLine("List is null");
return;
}
data[length] = a;
length++;
}
public void InsertNode(T a, int i)
{
if (IsFull())
{
Console.WriteLine("List is full");
return;
}
if (i < 1 || i > length + 1)
{
Console.WriteLine("Postition is error!");
return;
}
else
{
for (int j = length - 1; j >= i; j--)
{
data[j + 1] = data[j];
}
data[i - 1] = a;
}
length++;
}
public void DeleteNode(int i)
{
if (IsEmpty())
{
Console.WriteLine("list is empty");
return;
}
if (i < 1 || i > length)
{
Console.WriteLine("Position is error!");
return;
}
for (int j = i; j < length; j++)
{
data[j - 1] = data[j];
}
length++;
}
public T SearchNode(int i)
{
if (IsEmpty() || (i < 1) || (i > length))
{
Console.WriteLine("list is empty or Positon is error!");
return default(T);
}
return data[i - 1];
}
public T SearchNode(T value)
{
if (IsEmpty())
{
Console.WriteLine("list is empty!");
return default(T);
}
int i = 0;
for (i = 0; i < length; i++)
{
if (data[i].ToString().Contains(value.ToString()))
{
break;
}
}
if (i >= length)
{
return default(T);
}
return data[i];
}
public int GetLength()
{
return length;
}
public void Clear()
{
length = 0;
}
public bool IsEmpty()
{
if (length == 0)
{
return true;
}
else
{
return false;
}
}
public bool IsFull()
{
if (length == maxsize)
{
return true;
}
else
{
return false;
}
}
}
class StuNode
{
private string stu_no;
private string stu_name;
private int stu_score;
public string Stu_no
{
get {
return stu_no;
}
set {
stu_no = value;
}
}
public string Stu_name
{
get {
return stu_name;
}
set {
Stu_name = value;
}
}
public int Stu_score
{
get {
return stu_score;
}
set {
stu_score = value;
}
}
public StuNode(string stu_no, string stu_name, int stu_score)
{
this.stu_no = stu_no;
this.stu_name = stu_name;
this.stu_score = stu_score;
}
public override string ToString()
{
return stu_no + Stu_name;
}
}
class SeqListApp
{
public static void Main()
{
ILinarList<StuNode> stuList = null;
Console.Write("请选择储存结构的类型:1.顺序表2.单连表3.双连表4.循环表:");
char seleflag = Convert.ToChar(Console.ReadLine());
switch (seleflag)
{
case '1':
Console.Write("请输入学生数:");
int maxsize = Convert.ToInt32(Console.ReadLine());
stuList = new SeqList<StuNode>(maxsize);
break;
}
while (true)
{
Console.WriteLine("请输入操作选项:");
Console.WriteLine("1.添加学生成绩");
Console.WriteLine("2.删除学生成绩");
Console.WriteLine("3.按姓名查询学生成绩");
Console.WriteLine("4.按学号查询学生成绩");
Console.WriteLine("5.按升序显示学生的成绩");
Console.WriteLine("6.按降序显示学生的成绩");
Console.WriteLine("7.退出");
seleflag = Convert.ToChar(Console.ReadLine());
switch (seleflag)
{
case '1':
{
char flag;
do
{
string stu_no;
string stu_name;
int stu_score;
Console.Write("请输入学号:");
stu_no = Console.ReadLine();
Console.Write("请输入姓名:");
stu_name =Console.ReadLine();
Console .Write("请输入学生成绩:");
stu_score = Convert.ToInt32(Console.ReadLine());
StuNode newNode = new StuNode(stu_no,stu_name,stu_score);
if(stuList.GetLength() == 0)
{
stuList.InsertNode(newNode,1);
}
else if (newNode.Stu_score>(stuList.SearchNode(stuList.GetLength()).Stu_score))
{
stuList.InsertNode(newNode,stuList.GetLength()+1);
}
else
{
for(int i = 1;i<=stuList.GetLength();i++)
{
if(newNode.Stu_score<=stuList.SearchNode(i).Stu_score)
{
stuList.InsertNode(newNode, i);
break;
}
}
}
Console.Write("还有学生成绩输入吗(Y/N):");
flag = Convert.ToChar(Console.ReadLine());
}
while(flag == 'Y');
break;
}
case '2':
{
StuNode temp;
Console.Write("请出输入要出删除学生的学号:");
string stu_no = Console.ReadLine();
for(int i = 1; i <= stuList.GetLength();i++)
{
temp = stuList.SearchNode(i);
if (temp.Stu_no == stu_no)
{
stuList.DeleteNode(i);
break;
}
}
break;
}
case '3':
{
StuNode temp;
Console.Write("请输入要查询学生的姓名:");
string stu_name = Console.ReadLine();
for (int i = 1; i <= stuList.GetLength(); i++)
{
temp = stuList.SearchNode(i);
if (temp.Stu_name == stu_name)
{
Console.WriteLine("{0}的成绩是:{1}",stu_name,temp.Stu_score);
break;
}
}
break;
}
case '4':
{
StuNode temp;
Console.Write("请输入要查询学生的学号:");
string stu_no = Console.ReadLine();
for (int i = 1; i <= stuList.GetLength(); i++)
{
temp = stuList.SearchNode(i);
if (temp.Stu_no == stu_no)
{
Console.WriteLine("学号为{0}的成绩是:{1}",stu_no,temp.Stu_score);
break;
}
}
break;
}
case '5':
{
StuNode temp = null;
for (int i = 1; i <= stuList.GetLength(); i++)
{
temp = stuList.SearchNode(i);
Console.WriteLine("{0}\t{1}\t{2}",temp.Stu_no,temp.Stu_name,temp.Stu_score);
}
break;
}
case '6':
{
StuNode temp = null;
for (int i = stuList.GetLength(); i >= 1; i--)
{
temp = stuList.SearchNode(i);
Console.WriteLine("{0}\t{1}\t{2}", temp.Stu_no, temp.Stu_name, temp.Stu_score);
}
break;
}
case '7':
{
return;
}
}
Console.Write("按任意键继续。。。");
Console.ReadLine();
}
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询