Third time job

Source: Internet
Author: User

The pointer is an address that points to a type:

We know that the C language type has Int,char,bool (this is not commonly used), generally we use Int,char to meet the general type requirements, if the length of the variable is too large, is to use long, float,double, about the length of the various types of problems, You can use sizeof (int) or sizeof (long) to see the individual types, small in the system. (This thing I don't know.) )

The pointer is a 8-byte (64 system).

List my understanding is to include the following characteristics:

(1). Divided by N nodes, (2). Each node is connected by a pointer (3) Each node consists of a precursor node and a rear drive node (4). The first node has no precursor node, and the tail node has no rear drive node;

To meet the above 4, we are called linked lists, since the list is made up of a number of nodes, and what is the node composed of? The node is composed of two parts, one is the data domain, is used to hold the valid data, and the second is the pointer field, which is used to point to the next node, and the following constructs the linked list data structure in C language, first of all the nodes should be constructed, and then all the nodes will be linked together, then form a chain list;

Source:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#define N 3
typedef struct NODE
{
Char name[20];
struct node *link;
}stud;
Stud * creat (int n)/* Create a single-linked list function */
{
Stud *p,*h,*s;
int i;
if ((h= (Stud *) malloc (sizeof (stud))) ==null)
{
printf ("Cannot allocate memory space!");
Exit (0);
}
h->name[0]= ' + ';
h->link=null;
P=h;
for (i=0;i<n;i++)
{
if ((s= (Stud *) malloc (sizeof (stud))) ==null)
{
printf ("Cannot allocate memory space!");
Exit (0);
}
p->link=s;
printf ("Please enter the name of the person in page%d:", i+1);
scanf ("%s", s->name);
s->link=null;
P=s;
}
return (h);
}
Stud * Search (stud *h,char *x)/* Find function */
{
Stud *p;
Char *y;
p=h->link;
while (P!=null)
{
y=p->name;
if (strcmp (y,x) ==0)
return (p);
else p=p->link;
}
if (p==null)
printf ("No data Found!");
}


Stud * SEARCH2 (stud *h,char *x)
/* Another lookup function that returns a pointer to the direct predecessor of the previous lookup function.
H is the table-head pointer, and X is a pointer to the name you want to find
In fact, the algorithm of this function is the same as the above lookup algorithm, just a pointer s, and s always point to the pointer p point to the node of the direct precursor,
The result returns s that is the previous node of the node you are looking for */
{
Stud *p,*s;
Char *y;
p=h->link;
S=h;
while (P!=null)
{
y=p->name;
if (strcmp (y,x) ==0)
return (s);
Else
{
p=p->link;
s=s->link;
}
}
if (p==null)
printf ("No data Found!");
}
void Insert (stud *p)/* Insert function, insert after pointer p/*
{
Char stuname[20];
Stud *s; /* Pointer S is the address of the Save new node */
if ((s= (Stud *) malloc (sizeof (stud))) ==null)
{
printf ("Cannot allocate memory space!");
Exit (0);
}
printf ("Please enter the name of the person you want to insert:");
scanf ("%s", stuname);
strcpy (S->name,stuname); /* Copy the pointer stuname The array element pointed to the new node's data field */
s->link=p->link; /* Point the link of the new node to the successor node of the original P-node */.
p->link=s; /*p node's link field points to the new node */
}


void del (stud *x,stud *y)/* Delete the function, where y is the pointer to the node to be deleted, and x is the pointer to the previous node of the node to be deleted */
{
Stud *s;
S=y;
x->link=y->link;
Free (s);
}



void print (Stud *h)
{
Stud *p;
p=h->link;
printf ("Data information is: \ n");
while (P!=null)
{
printf ("%s \ n", &* (P->name));
p=p->link;
}
}



void Quit ()
{
Exit (0);
}
void menu (void)
{
System ("CLS");
printf ("\t\t\t single-linked list C language implementation example \ n");
printf ("\t\t|--------------------|\n");
printf ("\t\t| |\n");
printf ("\t\t| [1] Establishment of a new table |\n ");
printf ("\t\t| [2] Finding Data |\n ");
printf ("\t\t| [3] Inserting Data |\n ");
printf ("\t\t| [4] Delete data |\n ");
printf ("\t\t| [5] Print Data |\n ");
printf ("\t\t| [6] Exit |\n ");
printf ("\t\t| |\n");
printf ("\t\t| If you do not create a new table, please set up first! |\n ");
printf ("\t\t| |\n");
printf ("\t\t|-------------------|\n");
printf ("\t\t Please enter your options (1-6):");
}
Main ()
{
int choose;
Stud *head,*searchpoint,*forepoint;
Char fullname[20];


while (1)
{
menu ();
scanf ("%d", &choose);
Switch (choose)
{
Case 1:
Head=creat (N);
Break
Case 2:
printf ("Enter the name of the person you are looking for:");
scanf ("%s", FullName);
Searchpoint=search (Head,fullname);
printf ("The name of the person you are looking for:%s", *&searchpoint->name);
printf ("\ n press ENTER to return to the main menu.) ");
GetChar (); GetChar ();
Break
Case 3:printf ("Enter the person you want to insert behind:");
scanf ("%s", FullName);
Searchpoint=search (Head,fullname);
printf ("The name of the person you are looking for:%s", *&searchpoint->name);
Insert (Searchpoint);
Print (head);
printf ("\ n press ENTER to return to the main menu.) ");
GetChar (); GetChar ();
Break
Case 4:
Print (head);
printf ("\ n Enter the name of the person you want to delete:");
scanf ("%s", FullName);
Searchpoint=search (Head,fullname);
FOREPOINT=SEARCH2 (Head,fullname);
Del (forepoint,searchpoint);
Break
Case 5:
Print (head);
printf ("\ n press ENTER to return to the main menu.) ");
GetChar (); GetChar ();
Break
Case 6:quit ();
Break
Default
printf ("You typed in illegal characters!) press ENTER to return to the main menu. ");
System ("CLS");
menu ();
GetChar ();
}
}
}

Experience:

Throughout the course design and experimental writing process, I changed the previous writing code of some habits, so that their development of software can more appropriate life, their own access to information from the Internet and collection of relevant information, not only enhance the ability to learn self-learning at the same time also enhance the ability to do, is my learning method on a larger breakthrough. In the past learning process, we will remember a lot of theoretical knowledge, but through the curriculum design, we learned how to deal with the theory and practice of the combination of issues.

The use of the system is more user-friendly, simple, as long as the operator can master the basic Windows system operation, learn to surf the Internet, you can easily master the use of the system. All data services are done on the server. As long as the server does not have problems, all data and operations of the security, reliability is satisfactory. The implementation and popularization of this system is expected to greatly reduce the complicated tasks of many school educational administration and improve work efficiency.

Of course, the Student information management system is a relatively large system, if the whole school to achieve pure automation management, the module involved in a lot of too much, I in this system, just realized a lot of basic functions, there are many management functions, such as: library lending management and student status and other information to hook up, The teacher's information should also involve the evaluation of the level of remuneration, and so on, are not in the development of the implementation of functions, can only be gradually implemented in the subsequent development.


Third time job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.