From 76b3ecbbd53ae6986db41a1433265157b28e5cd6 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 9 Apr 2020 10:05:23 +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'du5/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/du5/program.c b/du5/program.c index 91d89dd..32eddb6 100644 --- a/du5/program.c +++ b/du5/program.c @@ -21,31 +21,18 @@ int main(){ struct LIS list[100]; int count=keep(list); //printf("%d",count); -int pult=del(list,count); + //printf("%d",pult); Sort_Struct(list,count); +int pult=del(list,count); print(list,count); return 0; } int keep(struct LIS *list){ -char *array; -int stop,count; -int num; - for(int i=0; stop!=EOF; i++){ - array=(char*)malloc(100); - stop =0; - for(int j=0;stop!='\n';j++){ - stop=getchar(); - if(stop==EOF) break; - if(stop!='\n'){ - array[j]=stop; - } - } - if(stop==EOF) break; - sscanf(array,"%d %s %s",&list[i].num,list[i].sname,list[i].fname); - count++; - free(array); + int count; + for(count=0;fscanf(stdin,"%d %s %s",&list[count].num, list[count].sname, list[count].fname)==3;count++){ + for(int i=0;list[count].fname[i]!='\0';i++); } return count; } @@ -84,7 +71,6 @@ void Sort_Struct(struct LIS *list,int count){//bubble sort :) for(int k=0;k