diff --git a/du6/program.c b/du6/program.c index 4d6678f..448ca65 100644 --- a/du6/program.c +++ b/du6/program.c @@ -35,7 +35,9 @@ char keep(struct LIS* list,int places){ int count=0; char names[100]; for(;fgets(names,100,stdin);){ - if(names[0]=='\n') continue; + for(int i=0; i<100;i++){ + if(names[i]=='\n') continue; + } if(sscanf(names,"%s %s",list[count].fname,list[count].name)==2){ count++; if(places>=count){ @@ -82,18 +84,22 @@ 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){ + int i=1; + if(count==1){ + i=0; + } + 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){ + if(list[i].num==0 && list[i].fname[0]!='\n'){ 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++){ + for(int i=0;i<=count;i++){ if(list[i].num==3){ printf("%s\n",list[i].fname); }