From 502f97862d695cf9cfcb8c1275a358e58841ce11 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 16 Apr 2020 14:52:03 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'du6/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du6/program.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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); }