Question: In c language create a program that produces a randomised set of songs from a longer list. Detailed Specification Input The program takes its input
In c language create a program that produces a randomised set of songs from a longer list. Detailed Specification Input The program takes its input from a file specified as an argument to the program. If the file does not exists or is not readable, the program prints out an error message to this effect. If no file is specifed, the program searches in the current directory for a file called artistes+songs.txt. If no such file exists, the program prints a message No file found. and then prompts the user to enter the artistes and songs information from the keyboard according to the specified format.
The format of the file is as follows:
Artiste name
Song title***Song duration
Song title***Song duration ..
. Song title***Song duration
Artiste name
Song title***Song duration
Song title***Song duration
The program should sort the input by artiste name and then by song title. The program should then generate a random playlist of the songs given as input, according to the following constraints
: An artiste cannot have more than two songs in a row (so no triple play, as the radio DJs might say);
An artiste cannot have more than three songs in total in the playlist;
A song cannot appear twice in the playlist;
The total playlist length should be as close as possible to one hour. Specifically, the last song must start on or before 59:59. The randomised playlist and the total time should be printed out in the following format
: Randomised playlist
Artiste name: "Song title" (Song duration)
Artiste name: "Song title" (Song duration) .
.. Artiste name: "Song title" (Song duration)
Total duration:
THIS IS WHAT I HAVE SO FAR,BUT I A M NOT SURE HOW TO IMPLEMENT THE SELECTION SORT OR FISHER YATES ALGORITHM IN REFERENCE TO THIS ASSIGNMENT. CAN SOMEONE PLEASE HELP,THANK YOU.
#inlude
#inlude
#inlude
#define MX 9999
strut MUSI{
hr rtist[MX];
hr sng[MX];
duble length;
} rerd;
int min()
{
hr dt[MX][MX];
int i;
FILE *fp = fpen("sngs.txt", "r+");
//This will hek in se the input .txt file exists r nt
if ((fp = fpen("sngs.txt", "r")) == NULL) {
printf(".re yu sure this file exists? . ");
exit(0);
}
while(!fef(fp)) {
/*
* if dt line desn't ntin * then stre int rerd.rtist
* if dt line des ntin * then split the string using strtrk t stre the first hlf int rerd.sng
* nd the send hlf int rerd.length
*/
}
/* Implementtin f seletin srt t srt dt t print ut in the fllwing frmt:
* rtist:
* - Sng***Durtin
* - Sng***Durtin
* ...
*
* rtist:
* - Sng***Durtin
* - Sng***Durtin
* ...
*
*/
/* Implemettin f Fisher-Ytes lgrrithm
* t shuffle the list
*/
printf("%s", dt);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
