# include <stdio.h>
# include <malloc.h>
# include <string.h>
# include <stdlib.h>
# define ARR_SIZE 100
struct CD;
typedef struct
{
char *songName;
unsigned int minutes;
unsigned int seconds;
struct CD *cdSource;
struct Song *nextSong;
} Song;
typedef struct
{
struct Artist *artist;
char *cdTitle;
struct Song **song;
unsigned int songsNum;
} CD;
typedef struct
{
char *artistName;
struct CD **cd;
int numOfCd;
} Artist;
typedef struct
{
struct CD **cd;
unsigned int cdTotal;
struct Artist **artist;
unsigned int ArtistsNum;
struct Song *song;
} Store;
typedef struct
{
Song song;
struct node *next;
} Node;
void initial(char **songLength,char **title,char *cdTitle,char *artistName,int songsTotal,CD *cd);
int main ()
{
Store *store;
CD *cd;
Artist *artist;
Node *head;
int option,songsTotal,stop,j=0,i,k;
char **songLength=NULL,**title=NULL,*cdTitle,*artistNam e,temp[ARR_SIZE],temp2[100][100],temp1[100][100];
while (option!=7)
{ scanf("%d\n",&option);
switch (option)
{
case 1:
gets(temp);
cdTitle=malloc(strlen(temp)*sizeof(char));
strcpy(cdTitle,temp);
// puts(cdTitle);
temp[0]=NULL;
gets(temp);
artistName=malloc(strlen(temp)*sizeof(char));
strcpy(artistName,temp);
// puts(artistName);
temp[0]=NULL;
scanf("%d",&songsTotal);
// printf("%d\n",songsTotal);
songLength=(char **) calloc(songsTotal, sizeof(char *));
title=(char **) calloc(songsTotal, sizeof(char *));
stop=2*songsTotal;
for (i=0;i<=stop;i++)
{
gets(temp);
if ((i%2)==0)
{ songLength[j]=(char *) malloc(strlen(temp)+1);
for (k=0;k<=strlen(temp);k++)
songLength[j][k]=temp[k];
songLength[j][k]=0;
temp[0]=NULL;
j++;
}
else if ((i%2)==1)
{ title[i-j]=(char *) malloc(strlen(temp)+1);
for (k=0;k<=strlen(temp);k++)
title[i-j][k]=temp[k];
title[i-j][k]=0;
temp[0]=NULL;
}
}
for (i=0;i<songsTotal;i++)
{ for (j=0;title[i][j]!='\0';j++)
{
printf("%c",title[i][j]);
}
printf("\n");
}
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
default:
printf("error\n");
}
}
return 0;
}
void initial(char **songLength,char **title,char *cdTitle,char *artistName,int songsTotal,CD *cd)
{
int i=0,j,k,digit,num;
cd[i].artist=malloc(strlen(artistName)*sizeof(char));
strcpy(cd[i].artist,artistName);
cd[i].cdTitle=malloc(strlen(cdTitle)*sizeof(char));
strcpy(cd[i].cdTitle,cdTitle);
cd[i].songsNum=malloc(strlen(songsTotal)*sizeof(char));
strcpy(cd[i].songsNum,songsTotal);
cd[i].song=(char **) calloc(songsTotal, sizeof(char *));
for(j=0;j<songsTotal;j++)
{ cd[i]->song[j]->songName=malloc(strlen(cdTitle[j])*sizeof(char));
strcpy(cd[i]->song[j]->songName,cdTitle[j]);
for (k=0;k<5;k++)
{
if (k<2)
{
digit=songLength[j][k]-48;
num=num*10+digit;
cd[i]->song[j]->minutes=num;
}
if (k>2)
{
digit=songLength[j][k]-48;
num=num*10+digit;
cd[i]->song[j]->seconds=num;
}
}
cd[i]->song[j]->cdSource=&cd[i];
if (j<songsTotal-1)
cd[i]->song[j]->nextSong=&cd[i]->song[j+1];
i++;
}
}