#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define LEN 5
typedef struct data{
char * student;
struct data * next;
}stu;
void push(stu * data,char * val)
{
stu * temp=(stu *)malloc(sizeof(stu));
temp->student=val,temp->next=NULL;
while(data->next!=NULL) data=data->next;
data->next=temp;
}
void print(stu * data)
{
if(data->next==NULL) return;
printf("%s : ",data->student);
while(data->next->next!=NULL)
{
data=data->next;
printf("%s, ",data->student);
}
printf("%s\n",data->next->student);
}
int main()
{
stu data[8];
char * key=(char *)malloc(sizeof(char)*3);
char * value[LEN];
int i;
data[0].student="A+",data[1].student="A0";
data[2].student="B+",data[3].student="B0";
data[4].student="C+",data[5].student="C0";
data[6].student="D+",data[7].student="D0";
for(i=0;i<8;i++) data[i].next=NULL;
for(i=0;i<LEN;i++) value[i]=(char *)malloc(sizeof(char)*100);
for(i=0;i<LEN;i++)
{
printf("insert %d key\n",i+1);
scanf("%s",key);
printf("insert %d value\n",i+1);
scanf("%s",value[i]);
if(!strcmp(key,"A+")) push(&data[0],value[i]);
if(!strcmp(key,"A0")) push(&data[1],value[i]);
if(!strcmp(key,"B+")) push(&data[2],value[i]);
if(!strcmp(key,"B0")) push(&data[3],value[i]);
if(!strcmp(key,"C+")) push(&data[4],value[i]);
if(!strcmp(key,"C0")) push(&data[5],value[i]);
if(!strcmp(key,"D+")) push(&data[6],value[i]);
if(!strcmp(key,"D0")) push(&data[7],value[i]);
}
for(i=0;i<8;i++) print(&data[i]);
return 0;
}