#include<constream.h>
struct st
{
int id;
char n[20];
float gpa;
st *next;
st *pr;
};
st *first=NULL;
void add(void)
{
st *temp=new st;
cin>>temp->id;
cin>>temp->n;
cin>>temp->gpa;
temp->next=NULL;
if(first==NULL)
{
first=temp;
first->next=temp;
first->pr=temp;
}
else
{
st *ptr=first;
if(ptr->next!=first)
{
ptr=ptr->next;
}
ptr->next=temp;
temp->next=first;
first->pr=temp;
}
}
void disp(void)
{
st *t=first;
do
{
cout<<t->id;
cout<<t->n;
cout<<t->gpa;
t=t->next;
}
while(t!=first);
getch();
}
void main(void)
{
int i;
do
{
clrscr();
cin>>i;
switch(i)
{
case 1:add();break;
case 2:disp();break;
}
}
while(i!=4);
}
Bookmarks