(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.

Source: Internet
Author: User

#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.

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.