Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Test case 6 Test case 7 Test case 8 Test case 9 Test case 1 0 Test case 1 1 Test case 1 2 Test
Test case
Test case
Test case
Test case
Test case Test case
Test case
Test case
Test case
Test case Test case
Test case
Test case
Test case Name,Email,Join Time,Leave Time,DurationMinutes
Feyza Nur
Duman,fnur.duman@tedu.edu.tr::::
Eda Nur
YILMAZ,enur.yilmaz@tedu.edu.tr::::
Serhat Gokhan
YAMAC,sgokhan.yamac@tedu.edu.tr::::
Duru Yamac,,::::
Asya Hale
Gencel,ahale.gencel@tedu.edu.tr::::
Eda Nur
YILMAZ,enur.yilmaz@tedu.edu.tr::::
Taner
Ceyhun,tanerceyhun@tedu.edu.tr::::
Sevil
TERZI,sevil.terzi@tedu.edu.tr::::#include
#include
#include
#include for tolower function
#define MAXNAMELENGTH
#define MAXEMAILLENGTH
#define MAXLINELENGTH
#define MAXATTENDEES
typedef struct
char firstNameMAXNAMELENGTH;
double totalDuration;
Attendee;
Fonksiyonun banda tanmlanmaldr
int compareAttendeesconst void a const void b
Attendee attendeeA Attendeea;
Attendee attendeeB Attendeeb;
return strcmpattendeeAfirstName, attendeeBfirstName;
void processAttendanceconst char filename, double minDuration, int sorted
FILE file fopenfilenamer;
if file NULL
printfUnable to open the file.
;
return;
char lineMAXLINELENGTH;
Attendee attendeesMAXATTENDEES;
int attendeeCount ;
Skip the header line
fgetsline MAXLINELENGTH, file;
while fgetsline MAXLINELENGTH, file NULL
char nameMAXNAMELENGTH;
double duration;
Parse the line to extract name and duration
sscanflinelf name, &duration;
Extract the names
char token strtokname;
char names;
int nameCount ;
Split the name into tokens
while token NULL && nameCount
namesnameCount token;
token strtokNULL;
Reorder the names
char firstNameMAXNAMELENGTH;
if nameCount
Son ismi baa al
strcpyfirstName namesnameCount ;
strcatfirstName;
for int i ; i nameCount ; i
strcatfirstName namesi;
strcatfirstName;
else
strcpyfirstName names;
Kk harfe dntrmeden nce orijinal ismi sakla
char originalNameMAXNAMELENGTH;
strcpyoriginalName firstName;
Kk harfe dntr
for int i ; firstNamei; i
firstNamei tolowerfirstNamei;
Ayn kii mi kontrol et
int existingIndex ;
for int i ; i attendeeCount; i
char tempMAXNAMELENGTH;
strcpytemp attendeesifirstName;
Kk harfe dntr
for int j ; tempj; j
tempj tolowertempj;
if strcmptemp firstName
existingIndex i;
break;
if existingIndex
Ayn kii ise sreyi ekle
attendeesexistingIndextotalDuration duration;
else
Yeni bir katlmc ise listeye ekle
strcpyattendeesattendeeCountfirstName, originalName;
attendeesattendeeCounttotalDuration duration;
attendeeCount;
fclosefile;
Sralkt isteniyorsa katlmclar srala
if sorted
qsortattendees attendeeCount, sizeofAttendee compareAttendees;
Katlmc bilgilerini gster
for int i ; i attendeeCount; i
if attendeesitotalDuration minDuration
printfs lf
attendeesifirstName, attendeesitotalDuration;
int main
char filenameMAXLINELENGTH;
double minDuration;
char sortedInput;
int sorted;
printfEnter the input file name, minimum duration, and 'sorted' option eg filename.txt sorted: ;
scanfs lf s filename, &minDuration, sortedInput;
Kk harfe dntr
for int i ; sortedInputi; i
sortedInputi tolowersortedInputi;
if strcmpsortedInput "sorted"
sorted ;
else
sorted
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started