This commit is contained in:
Michaela Šaková 2019-03-24 18:03:19 +01:00
parent 1b87440824
commit 3ce1e4ec5d
3 changed files with 7 additions and 20 deletions

BIN
anketa

Binary file not shown.

View File

@ -27,27 +27,14 @@ int search(struct student* students,const char* name){
}
int add_student(struct student* students, const char* name, int votes){
int index=-1, x=0;
for(int i=0; i<MAXSTUDENTS; i++){
if(strcmp(students[i].name,name)==0){
index=i;
break;
}
if(students[i].name!=NULL){
x++;
int index=search(students,name),pocet=count_students(students);
if(index==-1&&pocet<MAXSTUDENTS){
strcpy(students[pocet].name,name);
students[pocet].votes=votes;
}else if(pocet<MAXSTUDENTS){
students[index].votes+=votes;
}
}
if(index!=-1){
students[index].votes+=votes;
return index;
}
if(x<(MAXSTUDENTS-1)){
strcpy(students[x].name,name);
students[x].votes=votes;
return x;
}
return -1;

BIN
anketa.o

Binary file not shown.