Изменить 'du6/program.c'
This commit is contained in:
		
							parent
							
								
									eb9a6316e1
								
							
						
					
					
						commit
						7f4966f6fe
					
				| @ -4,7 +4,6 @@ | ||||
| #include <ctype.h> | ||||
| 
 | ||||
| struct LIS{ | ||||
| char name[100]; | ||||
| char fname[100]; | ||||
| int num; | ||||
| }; | ||||
| @ -34,52 +33,24 @@ else{ | ||||
| char keep(struct LIS* list,int places){ | ||||
| int count=0; | ||||
| char names[100]; | ||||
|     for(;fgets(names,100,stdin);){ | ||||
|         if(names[0]=='\n'){ | ||||
|     for(;fgets(list[count].fname,100,stdin);count++){ | ||||
|         if(list[count].fname[0]=='\n'){ | ||||
|             list[count].num=-1; | ||||
|             continue; | ||||
|         }     | ||||
|         if(sscanf(names,"%s %s",list[count].fname,list[count].name)==2){ | ||||
|             count++; | ||||
|             if(places>=count){ | ||||
|                 list[count-1].num=0; | ||||
|             } | ||||
|             else{ | ||||
|                list[count-1].num=1;  | ||||
|             } | ||||
|         } | ||||
|         else if(sscanf(names,"%s",list[count].fname)==1){ | ||||
|             count++; | ||||
|             if(places>=count){ | ||||
|                 list[count-1].num=2; | ||||
|             } | ||||
|             else{ | ||||
|                list[count-1].num=3;  | ||||
| //            printf("skip");
 | ||||
|         } | ||||
|         if(list[count].fname[0]!='\n'){ | ||||
|             list[count].num=0;     | ||||
|         }     | ||||
|     } | ||||
|     return count; | ||||
| } | ||||
| 
 | ||||
| void sort(struct LIS* list,int count){ | ||||
| 
 | ||||
| struct LIS ilusion; | ||||
| char *min; | ||||
| char *mickro; | ||||
| int mini; | ||||
|   if(list[0].num==0 || list[0].num==1) | ||||
|     for(int i=0;i<=count-1;i++){ | ||||
|         min=list[i].name; | ||||
|         mini=i; | ||||
|         for(int j=i+1;j<=count;j++){ | ||||
|             if(strcmp(min,list[j].name)>0){ | ||||
|                 min=list[j].name; | ||||
|                 mini=j; | ||||
|             } | ||||
|         } | ||||
|         ilusion=list[i]; | ||||
|         list[i]=list[mini]; | ||||
|         list[mini]=ilusion; | ||||
|     } | ||||
|     ////
 | ||||
|     for(int i=0;i<=count-1;i++){ | ||||
|         min=list[i].fname; | ||||
|         mini=i; | ||||
| @ -96,34 +67,29 @@ void sort(struct LIS* list,int count){ | ||||
| } | ||||
| 
 | ||||
| void print(struct LIS *list,int count,int places){ | ||||
| 
 | ||||
|     if(count>0){ | ||||
|         if(places>0){ | ||||
|             printf("Prijati studenti:\n"); | ||||
|             int i=1; | ||||
|             for(i;i<=count;i++){ | ||||
|                 if(list[i].num==2 && list[i].fname[0]!='\n'){ | ||||
|                     printf("%s\n",list[i].fname); | ||||
|                 } | ||||
|                 if(list[i].num==0 && list[i].fname[0]!='\n'){ | ||||
|                     printf("%s %s\n",list[i].fname,list[i].name); | ||||
|             int k=0; | ||||
|             puts("Prijati studenti:"); | ||||
|             for(int i=0;k!=places+1;i++){ | ||||
|                 if(list[i].num==0){ | ||||
|                 puts(list[i].fname); | ||||
|                 k++; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         if(count-places>0){ | ||||
|             printf("Neprijati studenti:\n"); | ||||
|             for(int i=0;i<=count;i++){ | ||||
|                 if(list[i].num==3){ | ||||
|                     printf("%s\n",list[i].fname); | ||||
|                 } | ||||
|                 if(list[i].num==1){ | ||||
|                     printf("%s %s\n",list[i].fname,list[i].name); | ||||
|             int k=0; | ||||
|             puts("Neprijati studenti:"); | ||||
|             for(int i=places+1;i<count;i++){ | ||||
|                 if(list[i].num==0){ | ||||
|                 puts(list[i].fname); | ||||
|                 k++; | ||||
|                 } | ||||
|             }             | ||||
|         } | ||||
|     } | ||||
|     else{ | ||||
|         puts("Ziadne prihlasky"); | ||||
|     } | ||||
| } | ||||
|    | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user