test
This commit is contained in:
		
							parent
							
								
									1b87440824
								
							
						
					
					
						commit
						3ce1e4ec5d
					
				
							
								
								
									
										27
									
								
								anketa.c
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								anketa.c
									
									
									
									
									
								
							| @ -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){ | ||||||
| 			} | 			students[index].votes+=votes; | ||||||
| 		if(students[i].name!=NULL){ | 		} | ||||||
| 			x++; |  | ||||||
| 		}	 |  | ||||||
| 	} |  | ||||||
| 	 | 	 | ||||||
| 	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; |  return -1; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user