From 33caa1cbbd7466715b9fefaff88972e38b846cfd Mon Sep 17 00:00:00 2001 From: Nazar Sendetskyi Date: Tue, 14 Jun 2022 07:43:18 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D0=BB(=D0=B0)=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20'du6?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du6/program | Bin 0 -> 21168 bytes du6/program.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 du6/program create mode 100644 du6/program.c diff --git a/du6/program b/du6/program new file mode 100644 index 0000000000000000000000000000000000000000..323c2e09073c67d7ac44b81f74ffa327621b02bd GIT binary patch literal 21168 zcmeHPdr%z5neW|YU=Xk@LJyGaXst+&9EAn+GDso@1k&P@WZ4!8cI1qf-2pb*2i^w; zpC7U@NeCuERe3mdszgq%Dz3zF$*HTH;`nSiaxD4E=R@&TqFj;-cV%C|RuYWkD%nt13E_Hw0RnZjl_4oT8-TigXZ1>Fc+~2-`uhZdRD!JH)8F5n;0%?|l{tlS| zX=V+q49AUZ11khyz%e0j76ej}E;)0lE^!wq*;P?y5qgz?nWCzOM9D5+YAzNMMVUwN zWT#P9@^;!@B=i(j@@#otA!jyPCEKT{)sAA*RU_=WnsVtGX?HZN?v|s%x>2u?d-Ho>MKfRP`dTCROrts?~t@R?B#BlogNV| zQ&g3AGwdiX|J|gz`4(ATzJ7R2#$QnxURE0kckkF%8wu4!!m;#V&0xchnjPDG$+&L| zuL9MJ%Ahf|?_ei`o3n(;F!H`wA$gKtc-%AD_Ve%Ezp3W4{s&h+P&PdH!9wMO$|N01 zWUqz<@swYVf6@`{f0P}USS9F1^W|u7XFxRKoi2;je@`C#FZ1A2z`gjlCj-D@{!8-UzXk5azdc0&tha;U z>+oNJUhp&vp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lLxQK zgSP;u_Oj;OHqZ^H#r$^z_vWf{?oQwp&T6LazbTdb^7uJH`c#5+Mk@eHr?@`OFS+`s z6)&Zy@$bQT>TM=&KJAnGQ}Q}b_s%Gt22T3+etcT$+i!q8Cvp32f*)~Q__Q7`OMSIq zQLFFY0jD_F%cXUX*Xls#*8pF?2+o3u6y8w68{0uPzt!AGMU5bBHm9BPp}5f-iFXGg zMhKI|q!CCD@<~_3Oqn5HL){KcffrMv9r0l!kVpiEFi}q>hOhxX5XG!59gPmb#KIZS zOy#J~FZc{&?=39{+Ku*uZ3Z^F=c;0w*>>B(mIEDoawUA%Js`}Vjds8E;BUKy8T2`}+Bnf`LydsPRPKSXlJK3AtZ&nD;{=X1?T56iWrrR6@`` zmBX^lO!PBf467?2?vMB|l>5y@YRCe0r^EPCN;o8;mevj|&UzVF@5ADY`9ec66d@>9 zid-^)wJ(-qIg9~W!i)sSK<4@*DdywB@*(T%jf163(hM?R${YksXC}1ce9ZaGK6x(o zh2Twb!iP91g@wwas6aFfXTlsE!hBeTMRAe?GrQBh&W> zU!O}YL{P!fe6b7G{|uvd{-FpgBDDqpSh6jjepg|_ga@ktPuuL(I$6<4 zWhklgr|9==_G+o$CK@0iz}=dv!meOHRNaBO^;v z_KMOv(Q40{rE;C1svPA)*(sjh87EAYujbpHJoa{f6|#J(uG}(Zzd4JD4AqsAqHCnR zK +#include +#include +#include + +#define ROZMER 100 +int compare(const void* a1, const void* a2){//na triedenie poľa + char* string1 = *((char**)a1); + char* string2 = *((char**)a2); + int r = strcmp(string1,string2); + return r; +} + +int printStatus(int pocet_mien_v_poli,int number_list){ + if (number_list < 0 || number_list == 0) + { + printf("Nespravny vstup\n"); + return 0; + } + if (pocet_mien_v_poli==1) + { + printf("Ziadne prihlasky\n"); + return 0; + } + return 1; +} +void printAllStudents(int pocet_mien_v_poli, int number_list, char* pole_smernikov[ROZMER]){ + for (size_t i = 0; i <=number_list ; i++) + { + if (pole_smernikov[i]!=NULL) + { + printf("%s",pole_smernikov[i]); + } + } + if (number_list+1 < pocet_mien_v_poli) + { + printf("Neprijati studenti:\n"); + } + for (size_t i = number_list+1; i < pocet_mien_v_poli ; i++) + { + if (pole_smernikov[i]!=NULL) + { + printf("%s",pole_smernikov[i]); + } + } +} + +int main(){ + int pocet_mien_v_poli = 0; + int number_list = 0; + char* pole_smernikov[ROZMER]; + memset(pole_smernikov,0,ROZMER*sizeof(char*)); + scanf("%d", &number_list); + + // prečítať všetkých študentov z terminálu + while (true) + { + char line[ROZMER]; + memset(line,0,ROZMER); + char* r = fgets(line,ROZMER,stdin); + int pocet_znakov = 0; + if (r!=NULL){ + pocet_znakov = strlen(line); + }else{ + break; + } + bool find = false; + for (int i = 0; i < pocet_mien_v_poli; i++){ + if (memcmp(pole_smernikov[i],line,pocet_znakov) == 0){ + find = true; + } + } + if(find == false){ + pole_smernikov[pocet_mien_v_poli] = calloc(' ',pocet_znakov + 1); + memcpy(pole_smernikov[pocet_mien_v_poli],line,pocet_znakov + 1); + pocet_mien_v_poli ++; + } + find = false; + } + + if (printStatus(pocet_mien_v_poli, number_list) == 0){ + return 0; + } + + qsort(pole_smernikov,pocet_mien_v_poli,sizeof(char*),compare);//triedi pole pomocou komparátora + + printf("Prijati studenti:"); + printAllStudents(pocet_mien_v_poli,number_list,pole_smernikov); + + for (int i = 0; i < pocet_mien_v_poli; i++){ + free(pole_smernikov[i]); + } +} \ No newline at end of file