From 9f3a2b94d65d447b89339a2357fb1f600efb7249 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Wed, 8 Apr 2020 18:19:24 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=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 | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 du5/program.c diff --git a/du5/program.c b/du5/program.c new file mode 100644 index 0000000..a454069 --- /dev/null +++ b/du5/program.c @@ -0,0 +1,94 @@ +#include +#include +#include +#include + + +struct LIS{ + +char fname[100]; +char sname[100]; +int num; +}; + +int keep(struct LIS *); +int del(struct LIS *,int); +void Sort_Struct(struct LIS *,int); +void print(struct LIS *,int); + + +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); +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; + array[j]=stop; + } + if(stop==EOF) break; + sscanf(array,"%d %s %s",&list[i].num,list[i].sname,list[i].fname); + count++; + free(array); + } + return count; +} + +int del(struct LIS *list,int count){ + for(int i=0;i1;j--){ + if(strcmp(list[i].sname,list[j].sname)!=0){ + for(int k=0;klist[j].sname[k]){ + ilusion=list[i]; + list[i]=list[j]; + list[j]=list[i]; + } + } + } + + } + } +} + +void print(struct LIS *list,int count){ + printf("Vysledky:\n"); + for(int i=0;i