From 8fe601683c6e0194b9b9a97e9f14c62e35bde459 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 16 Apr 2020 13:31:07 +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 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/du6/program.c b/du6/program.c index 45588ec..a768694 100644 --- a/du6/program.c +++ b/du6/program.c @@ -25,6 +25,7 @@ if(k!=1 || places<0){ else{ int count=keep(list,places); sort(list,count); + printf("%d",count); print(list,count,places); } return 0; @@ -34,7 +35,7 @@ else{ char keep(struct LIS* list,int places){ int count=0; char names[100]; - for(;fgets(names,100,stdin);){ + for(;fgets(names,100,stdin);count++){ if(sscanf(names,"%s %s",list[count].fname,list[count].name)==2){ if(places>=count){ list[count].num=0; @@ -42,7 +43,6 @@ char names[100]; else{ list[count].num=1; } - count++; } else if(sscanf(names,"%s",list[count].fname)==1){ if(places>=count){ @@ -51,7 +51,6 @@ char names[100]; else{ list[count].num=3; } - count++; } } return count; @@ -78,9 +77,9 @@ void sort(struct LIS* list,int count){ } void print(struct LIS *list,int count,int places){ - if(count>0){ + if(count>0){ if(places>0){ - printf("Prijati studenti:"); + puts("Prijati studenti:"); for(int i=0;i<=count;i++){ if(list[i].num==2){ printf("%s\n",list[i].fname);