From da7db7cb81862eb82b8f74200739559962f19a1e Mon Sep 17 00:00:00 2001 From: kr820js Date: Sat, 16 Mar 2024 20:11:32 +0100 Subject: [PATCH] submit1 --- cv5/program.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 cv5/program.c diff --git a/cv5/program.c b/cv5/program.c new file mode 100644 index 0000000..d705874 --- /dev/null +++ b/cv5/program.c @@ -0,0 +1,100 @@ +#include +#include + +#define SIZE 100 + +struct student { + char name[SIZE]; + int score; +}; + int compar(const void*,const void*); + +int main() +{ + struct student databaza[SIZE]; + memset(databaza,0,SIZE*sizeof(struct student)); + int size = 0; + while(loading_the_entire_line_from_standard_input_into_the_helper_field_and_verify_that_i_have_loaded_it_correctly(databaza,&size)){ + } + int element_size=SIZE+sizeof(int); + qsort((void *)databaza, size,element_size,compar); + for(int i=0; i 0){ + memcpy(name,end,velkost_mena); + } + else { + return; + } + adding_an_item_to_the_database( databaza, size_ptr, name, score); +} + +int retriving_integer(char *line,char** end){ + + int value = strtol(line,end,10); + if (value == 0){ + return 0; + } + return value; +} +int find_index(struct student databaza[],int size, const char *xxx){ + for(int i=0; iscore < b_ptr->score) { + return 1; + } + if(b_ptr->score > a_ptr->score) { + return -1; + } + if(a_ptr->score == b_ptr->score){ + return strcmp(a_ptr->name, b_ptr->name); + } +} +