线性表-链表啊

Comprehensive experiment 1:Application of linear list

One. Experimental target

1、Use the basic operations to implement the specific operations for the linear table;

2、Master the application of file operations;

3、Improve the understanding of the data structure of linked storage structure, and gradually cultivate the programming ability to solve practical problems.

Two. Experimental environment

A computer with Visual Studio.

This experiment has 4 class hours in all.

Three. Experiment content

1. address list design

Design a classmate’s address list, requested as follows:

Each student in the address list contains the following information: student id、name、telephone number. If you need more fields, please add them yourself.

The program has a main menu containing the following functions:

(1) Add a record: Add a student record from the input.

(2) Delete a record: Delete a student record according to the student id from the input.

(3) Output all records: Display all the records in the address list.

(4) Search by name: Input the student name and then output the whole information of the student.

(5) Save records: Save all the records in the address list to a certain file.

(6) Clear records: Delete all the records in the address list and then delete the file.

(7) Quit

hint**:**

When the program starts, it should be determined whether there is a record file. If the file exists, read each record from it to the list.

After the user selects and completes a function of the main menu, the program should return to the main menu.

When a record is added, it should be inserted into the tail of the list.

If a record does not exist when performing delete or and search operation, the program should output some information to the user.

You do not need to write files when adding records or deleting records.

When you want to save a record you’d better overwrite the file. (Or delete the original file first, and then save all the records)

Each module is written in the form of a function, called by the main function.

optional**:**

Add a sorting function in the main menu, the sorting result should be in an ascending order according to the student number. Sorting methods can be done by bubble sort or insert sort.

Four.Important data structures

Important data structures: the structure of linked lists

typedef struct stu {
	int id;			//id storage student ID
	char name[20];	//storage student name
	int tel;		//storage student telephone
	stu *next;		//Link to the next node
}stu;

Function Main Function and Query

	cout <<     "|*----------1:Create a large number of contacts-*|\
				 |*----------2:Insert a data---------------------*|\
				 |*----------3:Detele the data-------------------*|\
				 |*----------4:Disply all the Mail list----------*|\
				 |*----------5:Store to the file-----------------*|\
				 |*----------6:Clear the file--------------------*|\
				 |*----------7:Accurate search-------------------*|\
				 |*----------8:rough search----------------------*|\
				 |*----------0:exit------------------------------*|" << endl;

The main operation of address book function

stu*Create();                       // Bulk creation of data nodes
stu*Insert_(stu*head, stu*p);		// Insert data nodes
stu*Delete_(stu*head, int id);		// Delete data nodes
stu*Display_(stu*head);			// Show all nodes
stu*Find_(stu*head, char name[]);	// Find the required nodes by name
stu*Rough(stu*head, char name[]);	// Rough search, keyword search stu*Store_(stu*head);				// Store in a file
stu*Clear_(stu*head);				// Clear Nodes and Delete Files
int check_data(stu*head, int id, char name[], int tel);//Find out if there is duplicate data, and if there is duplicate data, it will not be stored in the table.

Five.Implementation analysis

Program Execution Structure Diagram

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值