Compare commits
No commits in common. "f8749e34279fd6ce766791c2bb0b3db5a6991944" and "f929cea52dd61725bb9b2859acaf83b04809351b" have entirely different histories.
f8749e3427
...
f929cea52d
@ -17,18 +17,4 @@ Chea
|
|||||||
CS78
|
CS78
|
||||||
2
|
2
|
||||||
50
|
50
|
||||||
20
|
20
|
||||||
SMC1
|
|
||||||
7890
|
|
||||||
CGS
|
|
||||||
4
|
|
||||||
40
|
|
||||||
50
|
|
||||||
60
|
|
||||||
70
|
|
||||||
CHS10
|
|
||||||
7823
|
|
||||||
CHS2
|
|
||||||
2
|
|
||||||
19
|
|
||||||
90
|
|
@ -45,7 +45,6 @@ void release(STUDENT *data);
|
|||||||
int find_min_in_array(int *array);
|
int find_min_in_array(int *array);
|
||||||
STUDENT *search_student_by_name_or_id(char search_key[NAME_SIZE]);
|
STUDENT *search_student_by_name_or_id(char search_key[NAME_SIZE]);
|
||||||
STUDENT *find_maximum_avg();
|
STUDENT *find_maximum_avg();
|
||||||
STUDENT *add_last_student(STUDENT *nodes, STUDENT *element);
|
|
||||||
|
|
||||||
// core functions
|
// core functions
|
||||||
void display_students();
|
void display_students();
|
||||||
@ -125,7 +124,6 @@ void display_students()
|
|||||||
|
|
||||||
void print_student(STUDENT *student)
|
void print_student(STUDENT *student)
|
||||||
{
|
{
|
||||||
int records_count = 0;
|
|
||||||
printf("\n================ Student Details ================\n");
|
printf("\n================ Student Details ================\n");
|
||||||
while (student != NULL)
|
while (student != NULL)
|
||||||
{
|
{
|
||||||
@ -143,12 +141,8 @@ void print_student(STUDENT *student)
|
|||||||
printf("]\n");
|
printf("]\n");
|
||||||
printf("Avg: %.2f\n", student->course_info.avg);
|
printf("Avg: %.2f\n", student->course_info.avg);
|
||||||
student = student->next;
|
student = student->next;
|
||||||
records_count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// output the records count
|
|
||||||
printf("\nRecords: %d has been loaded successfully!\n", records_count);
|
|
||||||
|
|
||||||
// clean up the memory
|
// clean up the memory
|
||||||
// after output the data
|
// after output the data
|
||||||
// because we don;t need it anymore after output
|
// because we don;t need it anymore after output
|
||||||
@ -241,7 +235,7 @@ void search_student()
|
|||||||
STUDENT *found_student = search_student_by_name_or_id(search_key);
|
STUDENT *found_student = search_student_by_name_or_id(search_key);
|
||||||
if (found_student == NULL)
|
if (found_student == NULL)
|
||||||
{
|
{
|
||||||
printf("\nNo student found!\n");
|
printf("No student found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,13 +254,6 @@ STUDENT *search_student_by_name_or_id(char search_key[NAME_SIZE])
|
|||||||
if (strcmp(temp->student_info.name, search_key) == 0 || strcmp(temp->student_info.id, search_key) == 0)
|
if (strcmp(temp->student_info.name, search_key) == 0 || strcmp(temp->student_info.id, search_key) == 0)
|
||||||
{
|
{
|
||||||
printf("\nSearch found with key: %s\n", search_key);
|
printf("\nSearch found with key: %s\n", search_key);
|
||||||
// set the temp next to null
|
|
||||||
// and free up the memory
|
|
||||||
temp->next = NULL;
|
|
||||||
free(temp->next);
|
|
||||||
|
|
||||||
// return the current temp
|
|
||||||
// that found in current search
|
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
temp = temp->next;
|
temp = temp->next;
|
||||||
@ -327,35 +314,6 @@ int find_min_in_array(int *array)
|
|||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
STUDENT *add_last_student(STUDENT *nodes, STUDENT *element)
|
|
||||||
{
|
|
||||||
STUDENT *temp = nodes, *node;
|
|
||||||
node = (struct student_tag *)malloc(sizeof(struct student_tag));
|
|
||||||
node->student_info = element->student_info;
|
|
||||||
node->course_info = element->course_info;
|
|
||||||
node->next = NULL;
|
|
||||||
|
|
||||||
if (nodes == NULL)
|
|
||||||
{
|
|
||||||
nodes = node;
|
|
||||||
|
|
||||||
return nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// store current as tempo
|
|
||||||
// ref for nodes
|
|
||||||
temp = nodes;
|
|
||||||
|
|
||||||
while (temp->next != NULL)
|
|
||||||
{
|
|
||||||
temp = temp->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
temp->next = node;
|
|
||||||
|
|
||||||
return nodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ISSUE: can't find all failed students
|
// ISSUE: can't find all failed students
|
||||||
// It's just return one record back
|
// It's just return one record back
|
||||||
STUDENT *find_failed_mark(int upper_mark)
|
STUDENT *find_failed_mark(int upper_mark)
|
||||||
@ -370,24 +328,28 @@ STUDENT *find_failed_mark(int upper_mark)
|
|||||||
int count = count_elements(temp);
|
int count = count_elements(temp);
|
||||||
printf("Temp count elements: %d", count);
|
printf("Temp count elements: %d", count);
|
||||||
|
|
||||||
int run_count = 0;
|
|
||||||
|
|
||||||
while (temp != NULL)
|
while (temp != NULL)
|
||||||
{
|
{
|
||||||
run_count++;
|
|
||||||
|
|
||||||
int min = find_min_in_array(temp->course_info.marks);
|
int min = find_min_in_array(temp->course_info.marks);
|
||||||
if (min < upper_mark)
|
if (min < upper_mark)
|
||||||
{
|
{
|
||||||
printf("\nRun min: %d\n", min);
|
if (failed_students == NULL)
|
||||||
failed_students = add_last_student(failed_students, temp);
|
{
|
||||||
|
failed_students = temp;
|
||||||
|
failed_students->next = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (failed_students->next != NULL)
|
||||||
|
{
|
||||||
|
failed_students = failed_students->next;
|
||||||
|
}
|
||||||
|
failed_students->next = temp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
temp = temp->next;
|
temp = temp->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\nRun count: %d", run_count);
|
|
||||||
|
|
||||||
return failed_students;
|
return failed_students;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user