Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize employee salary Management system with C language

Shulou Source: shulou.com Published: 2022-06-01 12:00:09 10月02日 Update

< z-1; i++)//因为进行两两比较,10个数最坏的情况就需要进行9趟 { for (int j = 0; j < (z-1) - i; j++)//因为每进行一趟就可以排好一个数,所以循环次数-i { if (s[j] >

S [juni1]) / / pairwise comparison {double temp = s [j]; s [j] = s [juni1]; s [juni1] = temp;} z muri; for (int I = z; I > = 0 If -) {if (storeNum = = s [I]) {continue;} p = head; while (p-> next! = NULL) {p = p-> next; storeNum = s [I] If (p-> salary==s [I]) {printf ("% d% s% s% d% s", p-> id, p-> name, p-> sex, p-> age, p-> department); switch (p-> post) {case 0: printf ("SALESMAN"); break Case 1: printf ("TECHNICIAN"); break; case 2: printf ("SALESMANAGER"); break; case 3: printf ("MANAGER"); break; default: printf ("incorrect data! Break;} printf ("% d%. 2lf% .2lf\ n", p-> workHour, p-> sales, p-> salary);} break; case 2: int Post; z = 0; storeNum = 0.0 Printf ("Please enter position information: (SALESMAN = 0, TECHNICIAN, SALESMANAGER, MANAGER)\ n"); scanf ("% d", & Post); p = head; while (p-> next! = NULL) {p = p-> next If (p-> post==Post) {s [z] = p-> salary; zonal sorting;}} / / Bubble sort for (int I = 0; I

< z-1; i++) { for (int j = 0; j < (z-1) - i; j++)//因为每进行一趟就可以排好一个数,所以循环次数-i { if (s[j] >

S [juni1]) / / pairwise comparison {double temp = s [j]; s [j] = s [juni1]; s [juni1] = temp;} z muri; for (int I = z; I > = 0 If -) {if (storeNum = = s [I]) {continue;} p = head; while (p-> next! = NULL) {p = p-> next If (p-> salary== s [I] & & p-> post==Post) {storeNum = s [I]; printf ("d% s% s% d% s", p-> id, p-> name, p-> sex, p-> age, p-> department) Switch (p-> post) {case 0: printf ("SALESMAN"); break; case 1: printf ("TECHNICIAN"); break; case 2: printf ("SALESMANAGER"); break Case 3: printf ("MANAGER"); break; default: printf ("incorrect data! Break;} printf ("% d%. 2lf% .2lf\ n", p-> workHour, p-> sales, p-> salary);} break; case 0: break; default: printf ("input error! Please re-select. \ n ");} / Statistical data void Statistics () {printf (" hh\ n ");} / Save the linked list data to the file void Save () {Employee * p; p = head; I = 0; / / the first step is to store the node information in the linked list into the array while (p-> next! = NULL) {p = p-> next; employees [I] .id = p-> id Strcpy (employees [I] .name, p-> name); strcpy (employees [I] .sex, p-> sex); employees [I] .age = p-> age; strcpy (employees [I] .department, p-> department); employees [I] .post = p-> post; employees [I] .workHour = p-> workHour; employees [I] .sales = p-> sales / / monthly sales of employees [I]. Salary = p-> salary;// monthly salary;} / / the second step is to input the array data into the text file if ((fp = fopen ("employee.txt", "wb+")) = = NULL) {printf ("error opening file! \ n "); exit (1);} p = head; I = 0; while (p-> next! = NULL) {p = p-> next; if (fwrite (& employees [I], sizeof (struct Employee), 1, fp)! = 1) {printf (" error writing file! \ n ");} iTunes;} fclose (fp); printf (" successfully saved data to a text file employee\ n ");}

Main function:

# include "header .h" int main () {ListInitiate (& head); Load (); / load the existing data to the linked list Menu (); Save (); / / Save the data to the file printf ("Welcome to use it next time!\ n");} above is all the content of the article "how to implement the employee salary Management system in C language". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Employee data input information salary file sales node pointer menu selection position department function salary technology technician sales computer office name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi OPPO Reno Linux Shulou Tech Info Huawei