#include "stdio.h"
#include "conio.h"
#include "stdafx.h"
#include <iostream>
using namespace Std;
struct stu{
Char name[20];
char sex;
int no;
int age;
struct Stu * NEXT;
}*linklist;
struct Stu *creatlist (int n)
{
int i;
H is the head node, p is the previous node, S is the current node.
struct Stu *h,*p,*s;
h = (struct Stu *) malloc (sizeof (struct stu));
H->next = NULL;
P=h;
for (i=0;i<n;i++)
{
s = (struct Stu *) malloc (sizeof (struct stu));
P->next = s;
printf ("Please input the information of the Student:name sex no-age \ n");
scanf ("%s%c%d%d", s->name,&s->sex,&s->no,&s->age);
S->next = NULL;
p = s;
}
printf ("Create successful!");
return (h);
}
void DeleteList (struct stu *s,int a)
{
struct Stu *p;
while (S->age!=a)
{
p = s;
s = s->next;
}
if (s==null)
printf ("The record is not exist.");
Else
{
P->next = s->next;
printf ("Delete successful!");
}
}
void display (struct stu *s)
{
s = s->next;
while (S!=null)
{
printf ("%s%c%d%d\n", s->name,s->sex,s->no,s->age);
s = s->next;
}
}
int main ()
{
struct Stu *s;
int n,age;
printf ("Please input the length of seqlist:\n");
scanf ("%d", &n);
s = creatlist (n);
Display (s);
printf ("Please input the age:\n");
scanf ("%d", &age);
DeleteList (S,age);
Display (s);
return 0;
}
(4) A student's information is: Name, school number, gender, age and other information, with a linked list, the student information is linked together, give an age, in some linked lists to delete students ages equal to the student information.