Home > Back-end >  Urgent for bosses to help, made a simple c language Internet cafe management system, a problem don&#
Urgent for bosses to help, made a simple c language Internet cafe management system, a problem don&#

Time:03-14

This is the source code
# include "Mylist. H"
/* run this program using the console pauser or add your own getch, system (" pause ") or the input loop */

Void menu ()
{
Printf (" -- -- -- -- -- -- -- -- -- -- Internet cafe management system -- -- -- -- -- -- -- -- -- \ n ");
Printf (" \ \ t t1. Add member information \ n ");
Printf (" \ \ t t2. Browse member information \ n ");
Printf (" \ \ t t3. Delete member information \ n ");
Printf (" \ t \ t4. Add the Internet information \ n ");
Printf (" \ n \ t \ t5. Delete the Internet information ");
Printf (" \ t \ t6 find membership information \ n ");
Printf (" \ t \ t0 exit management system \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n ");
}
Struct Node * list=createList ();
Void keyDown ()
{
Int choice=0;
VIP data struct;
The scanf (" % d ", & amp; Choice);
The switch (choice)
{
Case 1:
Printf (" -- -- -- -- -- -- -- -- add member information -- -- -- -- -- -- -- -- -- \ n ");
Printf (" please enter the member name, id card number and membership number, telephone number, member points: ");
/* fflush (stdin); *///empty buffer
The scanf (" % c % d % d % d % d ", & amp; Data. The name, & amp; Data. The idN, & amp; Data. VIPN, & amp; Data. The PN, & amp; Data. The integral);
InsertNodeByHead (list, data);
break;
Case 2:
Printf (" -- -- -- -- -- -- -- - browse member information -- -- -- -- -- -- -- -- -- \ n ");
Printflist (list);
break;
Case 3:
Printf (" -- -- -- -- -- -- -- -- delete member information -- -- -- -- -- -- -- -- -- \ n ");
Printf (" please enter delete member number ");
The scanf (" % s ", data. VIPN);
DeleteAppoinNode (list, data. VIPN);
break;
Case 4:
Printf (" -- -- -- -- -- -- -- -- add Internet information -- -- -- -- -- -- -- -- -- \ n ");
Printf (" please enter the computer time, machine number \ n ");
The fflush (stdin);
The scanf (" % s % s ", data, time, data. CN);
InsertNodeByHead (list, data);
break;
Case 5:
Printf (" -- -- -- -- -- -- -- -- delete access to the Internet information -- -- -- -- -- -- -- -- -- \ n ");
break;
Case 6:
Printf (" -- -- -- -- -- -- -- -- to find membership information -- -- -- -- -- -- -- -- -- \ n ");
Printf (" please enter to find member number: ");
The scanf (" % s ", data. VIPN);
If (searchInfoByData (list, data. VIPN)==NULL)
{
Printf (" did not find relevant information, can't delete! \n");
System (" pause ");
}
The else
{
Printf (" # member name id number \ \ t t \ \ t t telephone number members integral computer time \ \ t t machine no. \ n ");
Printf (" % s \ \ t t % d % d % d % d \ \ t t t t % d % d \ \ n \ ", searchInfoByData (list, data VIPN) - & gt; Data. The name, searchInfoByData (list, data VIPN) - & gt; Data. The idN, searchInfoByData (list, data VIPN) - & gt; Data. VIPN searchInfoByData (list, data VIPN) - & gt; Data. The PN, searchInfoByData (list, data VIPN) - & gt; Data. J integral, searchInfoByData (list, data VIPN) - & gt; Data. Time, searchInfoByData (list, data VIPN) - & gt; Data. CN);
}
break;
Case 0:
Printf (" normal exit! \n");
System (" pause ");
exit(0);
break;
Default:
Printf (" choose wrong, entering a \ n ");
System (" pause ");
break;
}
WriteInfoToFile (list, "1. TXT");
}


Int main (int arg c, char * argv [])
{

ReadInfoFromFile (list, "1. TXT");
While (1)
{
The menu ();
KeyDown ();
System (" pause ");
system("cls");
}
System (" pause ");
return 0;
}





#include
#include


Struct VIP
{
Int the idN, VIPN, PN, integral, time, CN;//id card number, membership number, telephone number, members of integral, computer time, machine number
Char name [50].//member name
};
Struct Node
{
//int data;
VIP data struct;
Struct Node * next;
};
//create a table
Struct Node * createList ()
{
Struct Node * headNode=(struct Node *) malloc (sizeof (struct Node));
HeadNode - & gt; Next=NULL;
Return headNode;
}


//create node
VIP data struct Node * createNode (struct)
{
Struct Node * newNode=(struct Node *) malloc (sizeof (struct Node));
NewNode - & gt; Data=https://bbs.csdn.net/topics/data;
NewNode - & gt; Next=NULL;
Return the newNode;
}
//insert node
Void insertNodeByHead (struct Node * headNode, VIP data struct)
{
Struct Node * newNode=createNode (data);
//headers method
NewNode - & gt; Data=https://bbs.csdn.net/topics/data;
HeadNode - & gt; Next=newNode;
}
//delete the location on the
Void deleteAppoinNode (struct Node * headNode, int VIPN)
{
Struct Node * posNode=headNode - & gt; Next;
Struct Node * posFrontNode=headNode;
If (posNode==NULL)
{
Printf (" data is empty, can't delete! \n");
return;
}
//the name is the string
While (posNode - & gt; Data VIPN!=VIPN)
{
PosFrontNode=posNode;
PosNode=posFrontNode - & gt; Next;
If (posNode==NULL)
{
Printf (" did not find the specified location cannot be deleted! \n");
return;
}
}
//found
PosFrontNode - & gt; Next=posNode - & gt; Next;
Free (posNode);
}
//lookup
Struct Node * searchInfoByData (struct Node * headNode, int VIPN)
{
Struct Node * pMove=headNode - & gt; Next;
If (pMove==NULL)
return NULL;
While (pMove - & gt; Data. VIPN==VIPN)
{
PMove=pMove - & gt; Next;
}
Return pMove;
}
//file read
Void readInfoFromFile (struct Node * headNode, char * fileName)
{
//1. Open the
FILE *fp;
VIP data struct;
Fp=fopen (fileName, "r");
If (fp==NULL)
{
Fp=fopen (fileName, "w +");
}
//2. Read the file
While (fscanf (fp, "% s \ \ t t % s % s \ \ t t % s % s \ \ t t % s % s \ n", data. The name, the data. The idN, data. VIPN and data. The PN, data. The integral, the data, time, data. CN)!=(EOF)
{
InsertNodeByHead (headNode, data);
}
//3. Close the file
The fclose (fp);
}
//file write
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related