From 5d19c905dc27788bd5b25c88cf9dd57e0384ef1a Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 16 Apr 2020 00:16:00 +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 | 73 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/du6/program.c b/du6/program.c index 4dc97cd..3daa63a 100644 --- a/du6/program.c +++ b/du6/program.c @@ -3,12 +3,81 @@ #include #include +struct LIS{ + +char fname[100]; +char sname[100]; + +}; +char keep(struct LIS*,int); +void sort(struct LIS*,int); +void print(struct LIS *,int,int); int main(){ - - printf("Prijati␣studenti:\nJan␣Hrasko\n"); + +struct LIS list[100]; +int places=0; +int k; +k=scanf("%d",&places); +if(k!=1 || places<=0){ + puts("Nespravny vstup"); +} +else{ + int count=keep(list,places); + sort(list,count); + print(list,count,places); +} return 0; } +char keep(struct LIS* list,int places){ +int num=places; +int stop; +int count=0; +char fn[100]; + for(;stop!=EOF;count++,num--){ + stop=fscanf(stdin,"%s %s",list[count].sname,list[count].fname); + } + count=-2; + return count; + +} + +void sort(struct LIS* list,int count){ + struct LIS ilusion; + char *min; + int mini; + for(int i=0;i0){ + min=list[j].sname; + mini=j; + } + } + ilusion=list[i]; + list[i]=list[mini]; + list[mini]=ilusion; + } + +} +void print(struct LIS *list,int count,int places){ + int j=0; + if(places>0){ + puts("Prijati studenti:\n"); + for(;j