#include #include #include #include struct LIS{ char name[100]; char fname[100]; int num; }; char keep(struct LIS*,int); void sort(struct LIS*,int); void print(struct LIS*,int,int); int main(){ struct LIS list[100]; int places=0; int k; k=scanf("%d",&places); if(k!=1 || places<0){ puts("Nespravny vstup"); } else{ int count=keep(list,places); sort(list,count); print(list,count,places); } return 0; } char keep(struct LIS* list,int places){ int count=0; char names[100]; for(;fgets(names,100,stdin);){ 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; } } } return count; } void sort(struct LIS* list,int count){ struct LIS ilusion; char *min; int mini; for(int i=0;i0){ min=list[j].fname; mini=j; } } ilusion=list[i]; list[i]=list[mini]; list[mini]=ilusion; } } void print(struct LIS *list,int count,int places){ if(count>0){ if(places>0){ printf("Prijati studenti:\n"); for(int i=0;i<=count-1;i++){ if(list[i].num==2){ printf("%s\n",list[i].fname); } if(list[i].num==0){ printf("%s %s\n",list[i].fname,list[i].name); } } } if(count-places>0){ printf("Neprijati studenti:\n"); for(int i=0;i<=count-1;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); } } } } else{ puts("Ziadne prihlasky"); } }