Home > Back-end >  O bosses help me find the wrong ~ C language for beginners staff management system
O bosses help me find the wrong ~ C language for beginners staff management system

Time:09-22

The main. H:
# include
# include
# include
# define LEN sizeof (struct staff)
Struct Date
{
Int year;
Int the month;
Int day;
};
Struct staff
{
int num;
Char name [10].
Char sex [10].
Struct the Date Date;
Char school [10].
Char position [10].
Int wage;
Char address [10].
Char call [11];
Struct staff * next;
};
Int menu ();
Struct staff * init ();
Int the add (struct staff * head);
Void scan (struct staff * head);
Void sort (struct staff * head);
Void the inquire (struct staff * head);
Void del (struct staff * head);
Void the modify (struct staff * head);
Void the save (struct staff * head, int sum);
Void the load (struct staff * head, int sum);

# include "is the main. H"
Int main ()
{
Struct staff * head;
Int I, sum;
I=the menu ();
The head=init ();//set up with a node list
While (i>=0 & amp; & i
=6){switch (I)
{
Case 1: the sum=add (head); break;
Case 2: the load (head, sum); break;
Case 3: sort (head); break;
Case 4: the inquire (head); break;
Case 5: del (head); break;
Case 6: modify (the head);
}
Printf (" 1. Worker information add \ t2. The worker information browsing \ t3 sort by wage \ n4 interchange query by record of formal schooling \ t5 worker information delete \ t6 modify functions \ t7 has quit \ n ");
Printf (" choose (1-7) \ n ");
The scanf (" % d ", & amp; I);
While (i<0 | | i> 7)//if the input is not the Numbers 1 to 7, re-enter
{
Printf (" wrong choice, to choose (1-7)! \n");
The scanf (" % d ", & amp; I);
}
}
If (I==7) printf (" exit management system \ n ");
return 0;
}

Struct staff * init ()
{
Struct staff * head=(struct staff *) malloc (LEN);
The head - & gt; next=NULL;
return head;
}

# include "is the main. H"
Int the add (struct staff * head)
{
Int sum=0;
Struct staff * p, * tail=head;
P=(struct staff *) malloc (LEN);
While (tail - & gt; Next!=NULL)
Tail=tail - & gt; next;
Printf (" please input the worker number (0 to terminate the worker information add) : \ n ");
The scanf (" % d ", & amp; p-> Num);
While (p - & gt; Num!=0)
{
Printf (" please input your name: \ n ");
The scanf (" % s ", p - & gt; Name);
Printf (" please enter the gender (female or male) : \ n ");
The scanf (" % s ", p - & gt; Sex);
Printf (" please enter the date of birth with commas (middle) : \ n ");
The scanf (" % d, % d, % d ", & amp; (p - & gt; The date). Year, & amp; (p - & gt; The date). The month, & amp; (p - & gt; The date). Day);
Printf (" please enter degree: \ n ");
The scanf (" % s ", p - & gt; School);
Printf (" please enter the position: \ n ");
The scanf (" % s ", p - & gt; The position);
Printf (" please enter the salary: \ n ");
The scanf (" % d ", & amp; p-> Wage);
Printf (" please enter the address: \ n ");
The scanf (" % s ", p - & gt; Address);
Printf (" please enter the telephone: \ n ");
The scanf (" % s ", p - & gt; The call);
Tail - & gt; Next=p;
Tail=p;
P=(struct staff *) malloc (LEN);
Printf (" please input the worker number (0 to terminate the worker information add) : \ n ");
The scanf (" % d ", & amp; p-> Num);
}
Tail - & gt; next=NULL;
Free (p);
P=the head - & gt; next;
While (p!=NULL)
{
Sum=sum + 1;
}
Save (head, sum);
Return the sum.
}

# include "is the main. H"
Void scan (struct staff * head)
{
Struct staff * p;
If (the head - & gt; Next==NULL)
{
Printf (" \ n no data! \n");
return;
}
Printf (" \ n the worker information browsing: \ n ");
P=the head - & gt; next;
While (p!=NULL)
{
Printf (" % d. NO., name: % s, gender: % s, birth year/month/day: % d % % d/d, education: % s, officers: % s, salary: % d, address: % s, telephone: % s \ n ", \
p-> Num, p - & gt; The name, p - & gt; Sex, (p - & gt; The date). Year, (p - & gt; The date). The month, (p - & gt; The date). Day, p - & gt; School, p - & gt; The position of p - & gt; Wage, p - & gt; Address, p - & gt; The call);
P=p - & gt; next;
}
}

# include "is the main. H"
Void sort (struct staff * head)
{
Struct staff * p, * q;
Int t1;
Char t2 [11];
For (p=head - & gt; next; (p - & gt; Next)!=NULL; P=p - & gt; Next)
{
For (q=p - & gt; next; q!=NULL; Q=q - & gt; Next)
{
If (p - & gt; Num> Q - & gt; Num)
{
T1=p - & gt; Num.
p-> Num=q - & gt; Num.
Q - & gt; Num=t1;
T1=(p - & gt; The date). The year;
(p - & gt; The date). Year=(q - & gt; The date). The year;
(q - & gt; The date). Year=t1;
T1=(p - & gt; The date). The month;
(p - & gt; The date). The month=(q - & gt; The date). The month;
(q - & gt; The date). The month=t1;
T1=(p - & gt; The date). The day;
(p - & gt; The date). Day=(q - & gt; The date). The day;
(q - & gt; The date). Day=t1;
T1=p - & gt; Wage;
p-> Wage=q - & gt; Wage;
Q - & gt; Wage=t1;//
Strcpy (t2, p - & gt; Name);
Strcpy (p - & gt; The name of the q - & gt; Name);
Strcpy (q - & gt; The name, t2);
Strcpy (t2, p - & gt; Sex);
Strcpy (p - & gt; Sex, q - & gt; Sex);
Strcpy (q - & gt; Sex, t2);
Strcpy (t2, p - & gt; School);
Strcpy (p - & gt; School, q - & gt; School);
Strcpy (q - & gt; School, t2);
Strcpy (t2, p - & gt; The position);
Strcpy (p - & gt; The position, the q - & gt; The position);
Strcpy (q - & gt; The position, t2);
Strcpy (t2, p - & gt; Address);
Strcpy (p - & gt; The address, the q - & gt; Address);
Strcpy (q - & gt; Address, t2);
Strcpy (t2, p - & gt; The call);
Strcpy (p - & gt; The call, the q - & gt; The call);
Strcpy (q - & gt; Call, t2);
}
}
}
}

# include "is the main. H"
Void the inquire (struct staff * head)
{
Char school [10].
Struct staff * p;
Int flag=0;
Printf (" please input to query degree: \ n ");
The scanf (" % s ", school);
If (the head - & gt; Next==NULL)
{
Printf (" no data! \n");
return;
}
P=the head - & gt; next;
While (p!=NULL)
{
While (STRCMP (school, p - & gt; School! nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related