Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use C language linked list to realize sales Management system

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to use C language linked list to achieve sales management system". The editor shows you the operation process through an actual case, the operation method is simple and fast, and has strong practicability. I hope this article "how to use C language linked list to achieve sales management system" can help you solve the problem.

Source code # include#include#includetypedef struct sale {char no [12]; / Code char name [40]; / / name int month [12]; / / month float sales [12]; / / monthly sales float total; / / Annual total sales struct sale * next; / / pointer to the next node} SALE / / the function declaration is put here void ListCreate (SALE * L, int n); / / create a linked list node void LIstSearch (SALE * L); / / find a salesperson's monthly sales void ListModify (SALE * L); / / modify a salesperson's monthly sales void ListDelete (SALE * L); / / delete a salesperson's sales information void Input (SALE * p, int I) / enter monthly sales and related information void Sum (SALE * L); / count total annual sales of all salespeople void SumSale (SALE * L); / output total annual sales of all salespeople void Max (SALE * L); / / find out maximum monthly sales and annual total sales void Min (SALE * L) / / find out the maximum monthly sales and total annual sales void Menu (); / / the menu of the sales management system / / the main function entry of the sales management system int main () {int item, n; / item to receive input commands, n to receive input salespeople SALE * L = NULL / / initialize a header node L = (SALE *) malloc (sizeof (SALE)); / / Open up memory space for the header node L-> next = NULL; / / empty the pointer domain of the header node do {Menu () / menu printf ("Please enter the appropriate number and do the appropriate operation:\ n"); scanf ("% d", & item); system ("cls"); switch (item) {case 1: printf ("Please enter the number of salespeople you want to enter:") Scanf ("% d", & n); ListCreate (L, n); getchar (); printf ("Please press any key to return to the main menu\ n"); getchar (); system ("cls"); break; case 2: LIstSearch (L); getchar () Printf ("\ nPlease press any key to return to the main menu\ n"); getchar (); system ("cls"); break; case 3: ListModify (L); / / modify a salesperson's monthly sales getchar (); printf ("\ nPlease press any key to return to the main menu\ n") Getchar (); system ("cls"); break; case 4: ListDelete (L); / / delete message getchar (); printf ("\ nPlease press any key to return to the main menu\ n"); getchar (); system ("cls"); break Case 5: Sum (L); SumSale (L); getchar (); printf ("Please press any key to return to the main menu\ n"); getchar (); system ("cls"); break; case 6: Sum (L); Max (L) Printf ("\ n"); Min (L); getchar (); printf ("Please press any key to return to the main menu\ n"); getchar (); system ("cls"); break Case 0: / exit the sales management system printf ("about to quit the sales management system."); exit (0); default: printf ("the instructions you entered are incorrect, please re-enter");} printf ("\ n\ n");} while (item); return 0 } / / create a linked list and insert the newly generated node into the header void ListCreate (SALE * L, int n) {int i; for (I = 0; I) of the linked list.

< n; i++) { SALE *p; //将新生成的节点插入到链表中 p = NULL; p = (SALE *)malloc(sizeof(SALE)); Input(p, i); p->

Next = L-> next; L-> next = p;} printf ("input successful!") ;} / / find a salesperson's monthly sales void LIstSearch (SALE * L) {int a; char n [40]; SALE * p = L-> next; if (p = = NULL) printf ("data is empty, cannot be found!") ; else {printf ("Please enter the name of the salesperson you are looking for:"); scanf ("% s", n); while (strcmp (p-> name, n)! = 0) {p = p-> next; if (p = = NULL) {printf ("relevant information not found\ n") Return;}} printf ("Please enter the sales volume of the month in which you want to find the salesperson:"); scanf ("% d", & a); printf ("salesman% s% d sales% .2f\ n", p-> name,a,p- > salesman [a-1]) }} / / modify a salesperson's monthly sales void ListModify (SALE * L) {int a; char nam [40]; SALE * p = L-> next; if (p = = NULL) printf ("data is empty and cannot be modified!") ; else {printf ("Please enter your modified salesperson name:"); scanf ("% s", nam); while (strcmp (p-> name, nam)! = 0) {p = p-> next; if (p = = NULL) {printf ("relevant information not found\ n") Return;}} printf ("Please enter the sales volume of the month in which you modified the salesperson:"); scanf ("% d", & a); printf ("Please enter the sales volume of your modified% d month:", a); scanf ("% f", & p-> salesman [a-1]); printf ("modified successfully") }} / / Delete salesperson sales information void ListDelete (SALE * L) {char n [40]; SALE * p = L-> next, * pre = L; / / define the point of p pointer to head node, define pre to head node, pre always points to p's precursor node if (p = NULL) printf ("data is empty and cannot be deleted!") ; else {printf ("Please enter the name of the salesperson you want to delete:"); scanf ("% s", n); while (strcmp (p-> name, n)! = 0) {pre = p; p = pre- > next If (p = = NULL) {printf ("No relevant information was found and cannot be deleted\ n"); return;}} pre- > next = p-> next; free (p); printf ("deleted successfully") Void Sum (SALE * L) {int i; SALE * paired L-> next; while (paired null) {p-> total=0; for [I]; pairp-> next;}} / / output the total annual sales of all salespeople void SumSale (SALE * L) {SALE * paired L-> next Printf ("\ n code\ t name\ t\ t total annual sales\ n"); while (paired null) {printf ("\ n% s\ t\ t% s\ t\ t% .2f", p-> no,p- > name,p- > total); pairp-> next;}} / / find the maximum monthly sales and annual total sales void Max (SALE * L) {int i; float massif 0 / m is used to indicate monthly sales, y is used to denote annual sales SALE * pendant L-> next; while (paired sales null) {for (itemisales [I] > m) massip-> sales [I];} if (p-> total > y) yearly sales-> total; pendant-> next;} printf ("maximum monthly sales is% .2f yuan\ n", m) Printf ("maximum annual sales of% .2f yuan\ n", y);} / / find out the minimum monthly sales and annual total sales void Min (SALE * L) {int i; float mdepartment; / / m is used to denote monthly sales, y is used to denote annual sales SALE * paired L-> next; massif p-> sales [0]; yearly p-> total; while (paired null) {for (item1) Isals [I] salesman [I];} if (p-> totaltotal; pairp-> next;} printf ("minimum monthly sales is% .2f yuan\ n", m); printf ("minimum annual sales volume is% .2f yuan\ n", y);} / enter relevant information about salesperson's monthly sales void Input (SALE * p, int I) {int j Printf ("Please enter the% d salesperson code:", I + 1); scanf ("% s", p-> no); printf ("Please enter the name of the% d salesperson:", I + 1); scanf ("% s", p-> name); printf ("Please enter the 12-month sales of the% d salesperson (separated by spaces):", I + 1); for (j = 0; j; j)

< 12; j++) { scanf("%f", &p->

Sales [j]); / / enter monthly sales}} / / menu of the sales management system void Menu () {printf ("\ n\ n"); printf ("\ t\ t\ tmanage = sales management system = =\ n"); printf ("\ t\ t\ t * author: XXX class: XXXXXXXXXXX student number: XXXXXXXXXX *\ n") Printf ("\ t\ t\ t *\ n"); printf ("\ t\ t\ t * 1 >. Enter the salesperson's monthly sales and its related information *\ n "); printf ("\ t\ t\ t * 2 >. Find a salesperson's monthly sales *\ n "); printf ("\ t\ t\ t * 3 >. Modify a salesperson's monthly sales *\ n "); printf ("\ t\ t\ t * 4 >. Delete a salesperson's sales information *\ n "); printf ("\ t\ t\ t * 5 >. Statistics of all salespeople's sales information *\ n "); printf ("\ t\ t\ t * 6 >. Find out the maximum (or minimum) monthly sales and total annual sales *\ n "); printf ("\ t\ t\ t * 0 >. Exit the management system *\ n "); printf ("\ t\ t\ t* Welcome to use this system! *\ n "); printf ("\ t\ t\ tkeeper =\ n ") Printf ("\ t\ t\ t enter options, press enter options:\ n");}

Main interface

On "how to use C language linked list to achieve sales management system" content is introduced here, thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report