From 2a26acc01f54f71aebdf80a4d2f174df0dcce706 Mon Sep 17 00:00:00 2001 From: Nazar Sendetskyi Date: Tue, 14 Jun 2022 07:42:52 +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'du5?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program | Bin 0 -> 21216 bytes du5/program.c | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 du5/program create mode 100644 du5/program.c diff --git a/du5/program b/du5/program new file mode 100644 index 0000000000000000000000000000000000000000..26c9fc77af6b544117cdc39dbae4bc81e74c9baf GIT binary patch literal 21216 zcmeHPdvsLCd7rzhD_tRJcO@YZ7{l_g1IAhj5Kn`VfQ2hr*w_XK@Z);54{6P6SKS8& z$2PKL*=&VUkv56al2}R3Nl8KylH<5`od?(s5TB+MNt?JQFUJR5u$>g+xFwG5?eCjA zvyUsuNqX{6do-Z^=6iqh&CK1Idw1>uZ`)>@qA*$P>_$eIyV9gI3C7DUq5{ywR0M{%p*$Sa1=ypKTtEI{~aF$7C63Pe(lHNpRw8Z2{$Xq5)dMZ@~ zZiO{dOgRZ9KkLtJ@|gv`L;@%h=Ic>z4%TrtJGjmQMP7yllzN1c-muUc7J3q168dRDke$V*5*sN8-&8TjA$+a~m;y15xPmHijrJv&Rr@|Hu%q79Xouoxu6u5j{$WTk~mg|&#H0gb0?r*I{}@B=XiGR zoq)b+0{X5A=wAihjX!H4pX2%cHt24vFz{CV%^Qcl60}M-lewBqrkocH{qLvlUcnN{ zxW9WpGmLN|=3l+qNcerx5bI7Q6QCuMKK~xW-?_&K`N9#%2EtL+9S=v7Ar|TgavA?V zpAia2eUb13L2j+98=B;R)Zm`4F9?hf6xlcOB^X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Fawgw0@2+5&@eXN*1Xkg zcyHch;1vahqFCi@+I4gD)|QQh9R7X;kgyCiyt=TUZ@P^cTiR~f(A;L+vU&6E-tETr z<_&FLvdZ78;7_D@&@3TVkstK#1oQO{O-=Is3-qo9dbvX(g|DUxNk-6IcUj&6krQeZ zFM`NX_h2&9}S*hr+clne+d`l$x>B*FGz9=D*5_y{~)1T3JPe||1jt{Wf7C{j|l$~ zE);t5`KUF1ANaW8m~Fq@k4U&pB#dIDs?^8bL0-c6B$v{^+_y+5?`50PrVUvq_!s!2 zXPZ)A?r$WN{U_s>auU)*FM3ugak&qYunBxB*7!{-V}qzrPNlxwFG={45S0F{?f<0E z-yr1V^I!>&=IK+;took?jq)n(-&^!Ygn)!n zej@$j7Ja$zldxMV3MlPK_>4v0E%p@>o|g%;=u5NTwdl)zq=XexP(W+`z9;l$|1-A` z6i__K5yY|c_Xprm|4IF+Qcu9Uz{@XI|33vYU%%UJN=w*D%)DYr2RjcQ?a9Qn&+c>O z`^2pB5|{8z=sNTCOe%1awe9;CH*}xXzWV=a^Ec94|hq#PxFt8)RX=HWza}O z>dW6>925)OeWa9Eq`ri-AIjHfO+vWAgwl^RA@w9qzi}s;^e@-Ht_k$5_9}&cAui1_ zslPZ&F)I`+6$xhweUqB|yg?YW+Ld}za?u3(dxYZe0xLD~NR-`i2+ literal 0 HcmV?d00001 diff --git a/du5/program.c b/du5/program.c new file mode 100644 index 0000000..c5529a7 --- /dev/null +++ b/du5/program.c @@ -0,0 +1,117 @@ +#include +#include +#include +struct clovek +{ + int holos; + char name[60]; +}; + +void printAll(struct clovek clovek[50],int number_clovek){ + printf("Vysledky:\n"); + for (size_t i = 0; i < number_clovek; i++) + { + printf("%d", clovek[i].holos); + printf("%s", clovek[i].name); + } +} +void readDellSame(bool je_toiste, bool je_dobre, int* number_clovek, struct clovek clovek[50]){ + for (size_t i = 0; i >=0; i++) + { + char step_name[60]; + int step_holos =0; + int r = scanf("%d", &step_holos); + if (r == -1) + { + break; + } + if (step_holos == 0) + { + je_dobre = true; + } + + fgets(step_name, 60 , stdin);//prečíta riadok z terminálu + for (size_t j = 0; j <*number_clovek; j++) + { + if(strcmp (clovek[j].name, step_name)==0 && je_dobre == false ){//porovnáva struny + clovek[j].holos += step_holos; + je_toiste = true; + i--; + } + } + if ((je_toiste == false|| *number_clovek == 0) && je_dobre == false) + { + clovek[i].holos = step_holos; + strcpy(clovek[i].name, step_name);//strcpy-koreluje časti pamäte + *number_clovek = *number_clovek +1 ; + } + je_toiste = false; + } +} + +void sortMas(int number_clovek, struct clovek clovek[50]){ + for (size_t i = 0; i clovek[j].name[1]){ + int tmp = clovek[i].holos; + char tmp_name[60]; + strcpy(tmp_name, clovek[i].name); + + clovek[i].holos = clovek[j].holos; + strcpy(clovek[i].name, clovek[j].name); + + clovek[j].holos = tmp; + strcpy(clovek[j].name, tmp_name); + } + if(clovek[i].name[1] == clovek[j].name[1]) + { + if(clovek[i].name[2] > clovek[j].name[2]){ + int tmp = clovek[i].holos; + char tmp_name[60]; + strcpy(tmp_name, clovek[i].name); + + clovek[i].holos = clovek[j].holos; + strcpy(clovek[i].name, clovek[j].name); + + clovek[j].holos = tmp; + strcpy(clovek[j].name, tmp_name); + } + } + } + } + } +} +int main(){ + struct clovek clovek[50]; + int number_clovek = 0; + bool je_toiste = false; + bool je_dobre = false; + readDellSame(je_toiste, je_dobre, &number_clovek,clovek); + for (size_t i = 0; i < number_clovek-1; i++) + { + for (size_t j = 0; j < number_clovek - i-1; j++) + { + if (clovek[j].holos < clovek[j+1].holos) + { + int tmp = clovek[j+1].holos; + char tmp_name[60]; + strcpy(tmp_name, clovek[j+1].name); + + clovek[j+1].holos = clovek[j].holos; + strcpy(clovek[j+1].name, clovek[j].name); + + clovek[j].holos = tmp; + strcpy(clovek[j].name, tmp_name); + } + + } + + } + sortMas(number_clovek, clovek); + printAll(clovek, number_clovek); + return 0; +} \ No newline at end of file