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

BIN
anketa.o

Binary file not shown.