#include<cstdio>
#include<cstdlib>
#include <cstring>
using namespace std;
struct node
{
int num;
char name[10];
struct node *next;
};
struct node *createlink(int n)
{
int i;
struct node *head,*p,*q;
head=(struct node*)malloc(sizeof(struct node));
head->next=head;
q=head;
for(i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p->num);
scanf("%s",p->name);
p->next=q->next;
q->next=p;
q=p;
}
q->next=head;
return head;
}
void disp(struct node *head)
{
if(head==NULL)
return;
struct node *p=NULL;
p=head->next;
while(p!=head)
{
printf("%d\n",p->num);
printf("%s\n",p->name);
p=p->next;
}
printf("\n\n");
}
int main()
{
struct node *head;
//struct node *data;
//scanf("%d",data->num);
//scanf("%s",data->name);
head=createlink(3);
//insertdata(head,data);
//sort(head);
disp(head);
return 0;
}
#include<cstdlib>
#include <cstring>
using namespace std;
struct node
{
int num;
char name[10];
struct node *next;
};
struct node *createlink(int n)
{
int i;
struct node *head,*p,*q;
head=(struct node*)malloc(sizeof(struct node));
head->next=head;
q=head;
for(i=0;i<n;i++)
{
p=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p->num);
scanf("%s",p->name);
p->next=q->next;
q->next=p;
q=p;
}
q->next=head;
return head;
}
void disp(struct node *head)
{
if(head==NULL)
return;
struct node *p=NULL;
p=head->next;
while(p!=head)
{
printf("%d\n",p->num);
printf("%s\n",p->name);
p=p->next;
}
printf("\n\n");
}
int main()
{
struct node *head;
//struct node *data;
//scanf("%d",data->num);
//scanf("%s",data->name);
head=createlink(3);
//insertdata(head,data);
//sort(head);
disp(head);
return 0;
}