Aktualizovat „du5/program.c“
This commit is contained in:
parent
d72315dc5d
commit
5f6f2ebd1e
@ -8,12 +8,13 @@ struct person{
|
|||||||
char name[30];
|
char name[30];
|
||||||
};
|
};
|
||||||
|
|
||||||
void addElement(struct person **PersonList,int score,char *name){
|
struct* addElement(struct person **PersonList,int score,char *name){
|
||||||
static int size = 1;
|
static int size = 1;
|
||||||
PersonList = realloc(PersonList,size*sizeof(struct person));
|
struct *Personlist = realloc(PersonList,size*sizeof(struct person));
|
||||||
PersonList[size-1]->score = score;
|
PersonList[size-1]->score = score;
|
||||||
strcpy(PersonList[size-1]->name ,name);
|
strcpy(PersonList[size-1]->name ,name);
|
||||||
size++;
|
size++;
|
||||||
|
return Personlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ int main(){
|
|||||||
int score=0;
|
int score=0;
|
||||||
int c =0;
|
int c =0;
|
||||||
while(scanf("%d %s",&score,name)!=EOF){
|
while(scanf("%d %s",&score,name)!=EOF){
|
||||||
addElement(&PersonList,score,name);
|
PersonList = addElement(&PersonList,score,name);
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user