This commit is contained in:
kr820js 2024-03-16 20:38:13 +01:00
parent c79bbf5d0b
commit 0216f95c75

View File

@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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){