程序员书籍笔记 程序员书籍笔记
  • HTML
  • CSS
  • JavaScript
  • 前端知识
  • Vue
  • MarkDown
  • git
  • Node.js
  • Linux
  • 51单片机
  • 四级
  • 第一学期课程
  • 操作系统
  • 计算机网络
  • 数据结构
  • 计算机组成原理
  • HTML5
  • Electron
  • 日记便签
  • 前端导航
GitHub (opens new window)
  • HTML
  • CSS
  • JavaScript
  • 前端知识
  • Vue
  • MarkDown
  • git
  • Node.js
  • Linux
  • 51单片机
  • 四级
  • 第一学期课程
  • 操作系统
  • 计算机网络
  • 数据结构
  • 计算机组成原理
  • HTML5
  • Electron
  • 日记便签
  • 前端导航
GitHub (opens new window)
  • 四级

  • ======第一学期======

  • 大学英语

  • 数据结构

    • 每周作业
    • 顺序链表课程设计报告
      • 顺序链表课程设计报告
      • 要求
      • 需求分析
      • 概要设计
        • ADT
        • 图形界面
        • 文件读写
        • 流程图
      • 程序运行结果
        • 增加数据
        • 删除数据
        • 修改数据
        • 查询数据!点击查询
    • 学生管理dos版1.0
    • lesson7

  • github英语

  • 软考专题

  • 学业和英语
  • 数据结构
yuadh
2022-03-05
目录

顺序链表课程设计报告

# 顺序链表课程设计报告

# 要求

使用顺序存储结构?

  • 系统的基本功能:实现学生信息的录入、查询、删除和修改
  • 录入-从键盘录入全班学生资料,并保存到文件中
  • 查询-据指定的学生信息,查询学生信息
  • 删除-删除一条学生信息
  • 修改-修改指定学生信息

学生信息格式:学号 姓名 C语言成绩

# 需求分析

编写一个使用顺序链表结构的学生成绩信息管理程序,学生成绩信息格式包含:学号、姓名、C语言成绩三项内容。学生成绩管理程序具有录入、查询、删除和修改功能。

# 概要设计

# ADT

数据结构层面的操作

自定义学生信息数据对象

typedef struct{
    int stuID;
    char *stuName;
    float stuScore;
}student;
1
2
3
4
5

定义线性表的顺序存储结构

#define MAXSIZE 100
typedef struct{
    student  stuDatas[MAXSIZE];
    int length;
}stuList;
1
2
3
4
5

对数据结构的操作

Operation

getstu(L,i,*e):获取链表第index位置的元素,返回给e

inserStu(*L,i,e):插入新元素e在链表第index的位置上

deleteStu(*L,i,*e):删除第index位置的元素

changeStu(*L,i,e):修改第index位置的元素为e

// 获取链表元素
STATUA getStu(stuList pro,int index,student *stuSomeOne){
    if(pro.length==0||index<1||index>pro.length){
        return ERROR;
    }
    *stuSomeOne = pro.stuDatas[index-1];
	return SUCCESS;
}
// 插入链表元素
STATUA insertStu(stuList *pro,int index,student stuSomeOne){
	if(index<1||index>pro->length+1){
		return ERROR;
	}
	if(index==pro->length+1){//在末尾插入
		pro->stuDatas[pro->length]=stuSomeOne;
		pro->length++;
	}else{//在中间插入 
		for(int i=pro->length;i>=index;i--){
			pro->stuDatas[i]=pro->stuDatas[i-1];	
		}	
		pro->stuDatas[index-1]=stuSomeOne;
		pro->length++;
	}
	return SUCCESS;
}
// 删除链表元素
STATUA deleteStu(stuList *pro,int index,student *stuSomeOne){
	int i;
	if(pro->length==0||index<1||index>pro->length){
		return ERROR;
	}
	//将index位置之后的元素前移
	for(i=index;i<=pro->length;i++){
		pro->stuDatas[i-1]=pro->stuDatas[i];
	}
	pro->length--;
	return SUCCESS;
}
// 修改链表元素
STATUA changeStu(stuList *pro,int index,student stuSomeOne){
	if(pro->length==0||index<1||index>pro->length){
		return ERROR;
	}
	pro->stuDatas[index-1]=stuSomeOne;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

# 图形界面

自娱自乐图形界面版,应用层面的操作

使用到:EasyX 、Win32api

enterPage() : 开始界面

mainPage(): 主程序界面

按钮实现

  • 对坐标位置的判断。。

页面显示

  • 画页面。。

防止页面一直刷新

int changeFlag = 1;
if(changeFlag){
	initMainDtaP(pro,0);//铺设数据页面	
	changeFlag--;
}
1
2
3
4
5

每次读写操作后写入文件,重新铺设数据 changeFlag++

应用层面操作

  • 根据数据结构的操作进行具体的增删查改。。

# 文件读写

void InitListReadFile(stuList *pro,char *fileName){//读文件操作
	FILE *fp;
	fp=fopen(fileName,"r");
	// printf("插入成功\n插入对象:");
	student stu;int index=0;
	while(fscanf(fp,"%d\t%s\t%f\n",&stu.stuID,stu.stuName,&stu.stuScore) != EOF){
		if(insertStu(pro,++index,stu)){
			printf("插入成功\n插入对象:");
			printf("%d %s  %.2f\n",stu.stuID,stu.stuName,stu.stuScore);
		}else{
			printf("插入失败\n");
			printf("%d %s  %.2f\n",stu.stuID,stu.stuName,stu.stuScore);
		}
	}
	fclose(fp);
}
void WriteListFile(stuList *pro,char *fileName){//写文件操作
	FILE *fp;
	fp=fopen(fileName,"w");
	if(fp==NULL){
		printf("文件打开失败");
		return ;
	}
	for(int i=0;i<pro->length;i++){
		fprintf(fp,"%d\t%s\t%f\n",pro->stuDatas[i].stuID,pro->stuDatas[i].stuName,pro->stuDatas[i].stuScore);
	}
	fclose(fp);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

# 流程图

流程图

# 程序运行结果

# 增加数据

点击增加

点击增加2

点击增加3

# 删除数据

点击删除

# 修改数据

点击修改

点击修改3

# 查询数据点击查询

编辑 (opens new window)
上次更新: 2023/02/07, 14:51:48
每周作业
学生管理dos版1.0

← 每周作业 学生管理dos版1.0→

Theme by Vdoing | Copyright © 2021-2023 yuadh
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式
×