From 0216f95c75fd3325738f9d48ebc763f89d5518d7 Mon Sep 17 00:00:00 2001 From: kr820js Date: Sat, 16 Mar 2024 20:38:13 +0100 Subject: [PATCH] submit4 --- cv5/program.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index 811f9ef..a7a3ae0 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -1,5 +1,6 @@ #include #include +#include #define SIZE 100 @@ -7,7 +8,12 @@ struct student { char name[SIZE]; int score; }; - int compar(const void*,const void*); +int compar(const void*,const void*); +int loading_the_entire_line_from_standard_input_into_the_helper_field_and_verify_that_i_have_loaded_it_correctly(struct student *databaza,int *size_ptr); +void parce_line_and_save_into_database(char line[],struct student *databaza, int *size_ptr); +int retriving_integer(char *line,char** end); +int find_index(struct student databaza[],int size, const char *xxx); +void adding_an_item_to_the_database(struct student databaza[],int *size_ptr, const char* name,int score); int main() { @@ -32,7 +38,7 @@ int loading_the_entire_line_from_standard_input_into_the_helper_field_and_verify char line[SIZE]; memset(line,0,SIZE); char* r = fgets(line,SIZE,stdin); - if (r == NULL){ + if (r == NULL||strlen(r)==1){ return 0; } parce_line_and_save_into_database(line,databaza,size_ptr); @@ -86,12 +92,12 @@ void adding_an_item_to_the_database(struct student databaza[],int *size_ptr, con } } int compar(const void* a,const void* b){ - struct student * a_ptr = a; - struct student * b_ptr = b; + const struct student * a_ptr = a; + const struct student * b_ptr = b; if(a_ptr->score < b_ptr->score) { return 1; } - if(b_ptr->score > a_ptr->score) { + if(a_ptr->score > b_ptr->score) { return -1; } if(a_ptr->score == b_ptr->score){