Aktualizovat „du5/program.c“
This commit is contained in:
		
							parent
							
								
									97741f611e
								
							
						
					
					
						commit
						5d515e9080
					
				@ -36,7 +36,7 @@ int main(){
 | 
				
			|||||||
	    if(str[0]=='\n'){
 | 
						    if(str[0]=='\n'){
 | 
				
			||||||
	        break;
 | 
						        break;
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	    sscanf(str,"%d %s",&score,name);
 | 
						    sscanf(str,"%d %[^\t\n]",&score,name);
 | 
				
			||||||
		PersonList[c].score = score;
 | 
							PersonList[c].score = score;
 | 
				
			||||||
	    strcpy(PersonList[c].name ,name);
 | 
						    strcpy(PersonList[c].name ,name);
 | 
				
			||||||
		c++;
 | 
							c++;
 | 
				
			||||||
@ -45,10 +45,11 @@ int main(){
 | 
				
			|||||||
	if(c>2){
 | 
						if(c>2){
 | 
				
			||||||
	    qsort(PersonList,c,sizeof(struct person),comp);
 | 
						    qsort(PersonList,c,sizeof(struct person),comp);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						int res_strcmp=0;
 | 
				
			||||||
	int idex = 0;
 | 
						int idex = 0;
 | 
				
			||||||
	for(int i =0;i<c;i++){
 | 
						for(int i =0;i<c;i++){
 | 
				
			||||||
		if(strcmp(PersonList[i].name,PersonList[i+1].name)==0){
 | 
						    res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name);
 | 
				
			||||||
 | 
							if(res_strcmp==0){
 | 
				
			||||||
			PersonList[i-idex].score += PersonList[i+1].score;
 | 
								PersonList[i-idex].score += PersonList[i+1].score;
 | 
				
			||||||
			idex++;
 | 
								idex++;
 | 
				
			||||||
		}	
 | 
							}	
 | 
				
			||||||
@ -61,11 +62,12 @@ int main(){
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	printf("Vysledok\n");
 | 
						printf("Vysledok\n");
 | 
				
			||||||
	for(int i =0;i<c;i++){
 | 
						for(int i =0;i<c;i++){
 | 
				
			||||||
		if(strcmp(PersonList[i].name,PersonList[i+1].name)!=0){
 | 
						    res_strcmp = strcmp(PersonList[i].name,PersonList[i+1].name);
 | 
				
			||||||
 | 
							if(res_strcmp!=0){
 | 
				
			||||||
			flag=0;
 | 
								flag=0;
 | 
				
			||||||
			printf("%d %s\n",PersonList[i].score,PersonList[i].name);
 | 
								printf("%d %s\n",PersonList[i].score,PersonList[i].name);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else if(strcmp(PersonList[i].name,PersonList[i+1].name)==0&&flag==0){
 | 
							else if(res_strcmp==0&&flag==0){
 | 
				
			||||||
		    flag=1;
 | 
							    flag=1;
 | 
				
			||||||
		    printf("%d %s\n",PersonList[i].score,PersonList[i].name);
 | 
							    printf("%d %s\n",PersonList[i].score,PersonList[i].name);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user