Aktualizovat „du5/program.c“

This commit is contained in:
Bohdan Yanchyk 2020-04-09 18:54:33 +00:00
parent f583b1cadc
commit f2a7087010

View File

@ -1,12 +1,13 @@
#include<stdio.h> #include<stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
struct person{ struct person{
int score; int score;
char name[30]; char name[30];
} };
void addElement(struct person PersonList*,int score,char *name){ void addElement(struct person* PersonList,int score,char *name){
static int size = 1; static int size = 1;
PersonList = realloc(PersonList,size*sizeof(struct person); PersonList = realloc(PersonList,size*sizeof(struct person);
PersonList[size-1]->score = score; PersonList[size-1]->score = score;
@ -25,7 +26,7 @@ int comp(const void *p1, const void *p2){
int main(){ int main(){
struct person PersonList*=(struct person *)calloc(0,sizeof(struct person)); struct person *PersonList=(struct person *)calloc(0,sizeof(struct person));
int count = 0; int count = 0;
char name[30]; char name[30];
int score=0; int score=0;