From a3fc14b073ea11c5c7dea2747b04192000515f7b Mon Sep 17 00:00:00 2001 From: Peter Petrek Date: Thu, 4 Nov 2021 18:12:07 +0100 Subject: [PATCH] first --- cv4/Makefile | 13 +++++++++++++ cv4/a_train.c | 38 +++++++++++++++++++++++++++++++++++++ cv4/a_train.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ cv4/a_train.o | Bin 0 -> 3564 bytes cv4/main.c | 19 +++++++++++++++++++ cv4/main.o | Bin 0 -> 2760 bytes cv4/train | Bin 0 -> 7946 bytes 7 files changed, 121 insertions(+) create mode 100644 cv4/Makefile create mode 100644 cv4/a_train.c create mode 100644 cv4/a_train.h create mode 100644 cv4/a_train.o create mode 100644 cv4/main.c create mode 100644 cv4/main.o create mode 100755 cv4/train diff --git a/cv4/Makefile b/cv4/Makefile new file mode 100644 index 0000000..3c2c463 --- /dev/null +++ b/cv4/Makefile @@ -0,0 +1,13 @@ +CFLAGS= -std=c99 -g -Wall + +all: train + +%.o: %.c + gcc -c -o $@ $< $(CFLAGS) + +train: main.o a_train.o + gcc main.o a_train.o -o train + +clean: + rm *.o train + diff --git a/cv4/a_train.c b/cv4/a_train.c new file mode 100644 index 0000000..d23eb1f --- /dev/null +++ b/cv4/a_train.c @@ -0,0 +1,38 @@ +#include "a_train.h" +#include +#include +#include + +struct car* add_car(struct car* first,const char* target) { + struct car* newcar = calloc(1,sizeof(struct car)); + newcar->next = NULL; + strcpy(newcar->value, target); + + if(first == NULL){ + return newcar; + } + + struct car* this = first; + while(this->next != NULL){ + this = this->next; + } + this->next = newcar; + + return first; +} + +void print_train(struct car* first) { + while(first != NULL){ + printf("%s\n", first->value); + first = first->next; + } +} + +void cancel_train(struct car* first) { +} + + +struct car* clear_train(struct car* first, const char* target) { + return NULL; +} + diff --git a/cv4/a_train.h b/cv4/a_train.h new file mode 100644 index 0000000..5982bfe --- /dev/null +++ b/cv4/a_train.h @@ -0,0 +1,51 @@ +#ifndef TRAIN_H +#define TRAIN_H +#define SIZE 100 + +/** + * Jeden vozen vlaku + */ +struct car { + /** + * Nazov cielovej stanice + */ + char value[SIZE]; + /** + * Smenik na dalsi vozen + */ + struct car* next; +}; + +/** + * Prida vozen na koniec vlaku. + * + * @arg nazov cielovej stanice, ktory sa ma priradit novemu voznu. + * @return smernik na zaciatok vlaku. + */ +struct car* add_car(struct car* first,const char* target); + + +/** + * Vypise vsetky vozne vo vlaku + * + * @arg smernik na prvy vozen + */ +void print_train(struct car* first); + +/** + * Zrusenie vsetkych voznov vo vlaku. + * @arg smernik na prvy vozen + */ +void cancel_train(struct car* first); + +/** + * Vyradenie vsetkych voznov, ktorych cielova stanica je target + * + * @arg smernik na prvy vozen + * @arg cielova stanica, ktora sa ma vyradit z vlaku. + * @return smernik na novy prvy vozen + * + */ +struct car* clear_train(struct car* first,const char* target); + +#endif // TRAIN_H diff --git a/cv4/a_train.o b/cv4/a_train.o new file mode 100644 index 0000000000000000000000000000000000000000..cd63b32d6f8ae1cfc2847ecf8282b8296b4aacbd GIT binary patch literal 3564 zcma)8TWnNC7@pZZyFF#M+Z$*F3=1uSA>HLtB0-RHDWpmWG1N#D%IWT5cguF$?4GTZ zK-3U|webQG&?jm_ln3z%6XS!?AR#6u`oM#a#6)6JO^V^oOZ~n%GrMQwgZ|0P_uuB9 zfBw0g^XkC8Cz5%(9f-z8L+1Z9?mt-3_P6a&w}-tb6-_| zBR4cZeJ~53Z*Qr|y5<&hfDQvzjj>g{`^x7C9Y5!^M{dm`pAcDL$yMlO6BH?>5Mowi zDC3kxK4c$&9G*iLijxg>i|~D7TTw|_VYy(AqD9zcMAT|(N4%(vehj(ET8$n$n;`8E z2%)C0edP;E8NI8Nk-q@86)BWF5w#<%UDR%xBv_G808Q4H=$kp;BFuoqqmo&W#(WTR zDJ-#jkYrS4ctOOzP!bm(x?siWAe($!KK>bPt-e$gE%GhOU6SE0plzYJyB4xbhZG69 zgq9VOPM6UpC>CpuD~w~Sd_YULN|cVXXxFKV-DBUa9sMM`b&@c&%hid_SU9mP(Jnh= zTNKH6%CH@aZH+x0lbzU<77DIVzFls0+nk8I|!q# zb=ZyOC*X%lrsR&eA81W{u#=PZM=$S+GgK^6n<9iM;(ZNbOK@bvxWvCLSNw>rL5rCU zHk5*d`r%}H7BTGeHc=HxRBa-+hCTpAluKyT5xEoKZQ{F%ui8ZJRB#;Si&{r~&*yF8 zCB;{5A~!8Kj`9_)Bl1LZKH^oyS8d{~;_G=XS28+LOI`U;LvqkUq8GiCeMB2)vvXJNRk@dPX%VvIJ0D)$zCM?}LH_O0_1iaWKO71n zq?64K^I}&^l|ruMW|O>Z8K;zSi+)tG@4!%Ucd{?_RBEG0=f}s~v{yahrYa}W6BFr8 z8#V#Z7e>?7isNkDkj_l@iQ;%Emuv{BG^*nSb*aH=q70*+wr0rWk)G;m!@Yc=B0Q&@ zb3IYXkC(m1x%5iZnB#?V#Sq$ehwV$~IyqU)6P9R64)RIg{HaLV`d6_Lc3Zb zp~7vrDBCt|>j~PADYLS_3_VX}Bxv7Rx1WZdrw>=L9)GWI7pcnBnCFZDy|Rya!NHsTHC>eW&Zz@R=|(10p34FeduR>R`upCErZk? z&~L+&(ghi>m>N$%JbGfamielX?)p&cO}ur`(Eq>um=E(a#CX>N3d634KA7Jj`qQx8>?PzS*w4eVUgtfx&eG?4G^^#`Mg6sGW>qtV!b+n<;kLzkj zGiL>?xQ=+AlF?-5C7L;Dn#E;42<2k%2{guIT+SJcH;_5*AQTADi#Qc2Ih(8i>1b))?d5wQ- zjH7&vyIf;85#!cqTt~$C&DuVoalf|n9?<^~5q?Lty`*tU+s|lxoe014+I~qRN-HGZ X2ktlHZPl0r;x9<_Ydog$HI4rOOw+u{ literal 0 HcmV?d00001 diff --git a/cv4/main.c b/cv4/main.c new file mode 100644 index 0000000..05dfd32 --- /dev/null +++ b/cv4/main.c @@ -0,0 +1,19 @@ +#include "a_train.h" +#include +#include +#include + +// Testovaci subor pre vlak +int main(){ + struct car* train = NULL; + train = add_car(train,"Presov"); + train = add_car(train,"Bratislava"); + train = add_car(train,"Levoca"); + train = add_car(train,"Spiska Nova Ves"); + print_train(train); + //clear_train(train,"Levoca"); + //print_train(train); + //cancel_train(train); + + return 0; +} diff --git a/cv4/main.o b/cv4/main.o new file mode 100644 index 0000000000000000000000000000000000000000..c18b5790a771ab79e33717994d7ff012cae6c255 GIT binary patch literal 2760 zcma)8PiP!f9DZ+Rc6ZuMwncr3bxZm!CZu22rOcrb0h%L`}cvi&H_bQ}x9&i;ZZ( zFU@v(e(6jQi60PdF-JJ^R*bTU;VyE>Y68Nl`k|;>?ku?d6$Wd7s&%KZuMmftiq(V@ zKzRXIhC@|ko!s|OvNHQJAm{8OadKH@bC(HL?qXtOMFf7RjG1o$u9IoBW07?;8#KDP z7YR=0O~5X>j#1{`#z-+smAlELt5y`F{c>3DD-`o~VYDzTN8}LZwu;hr^ZBFs2lL#n zJt*t~$xQJGvK=XBinM3;ikV_Lk15AQKL0REU<-So&cNwvn~SA*@{s{kfpZ+ozBM%< z#O}%Mx|UiM7lz9cu|u>I-6gIlz3URW6~+LR@C@l&q%HmJ(lDd^cVm?D&%z)^bzm`t z6fM8e_Nt8X=i-p0PJ+#;iZ@?aal6Uy!H-lS-D+ViCy#gyfr=4u@$Y&%df zPMZ|qBKmn`QN0t!I}7UttJHRIE*3q%*$s50%4wVr;-y8L(38{CM@##U2bG53PBt`t z{{g)-wB`oYAaw8i(?Tx0a&*9PUPm{1A9zvJaeK7jzGh7gW~^7QAVdf+T58391sI13 z){PbhO)uuEyqX{T!mC7)@WM_)=&S{m?)+S%eYS%TrTdji81xKlcB)9&4)jC6J&(sX zWokCsfr-Yn!mD;#tpLsP+MPJ?aQnui*sm@mIYE8yZ0NW6y#8Og1A#oZe0nK-=czs@ zh6hLEC~%k72^%1f1KC&RGY*f9;LCuV=bxfpU5TnjQ|}%y#{XB`eTZSb2Zco?hQ2ykv%8m%B(;xW_)K4@r>D9Xjt^AjWH9rl=cMOZG^GUNjnMbtVmVJUs)s*>#d-i%dEle)F^%KksN?>>ZtAJ)WGt*y_%wIX;3Z zvDMD|23xSJeX-FYGvg}EBe;WueYeVHAC0h&=7Xa?0Di4D$A2G-A>QH1CyXJ?k=QEx zYawY|^9M9Pq4`sqKd*U1^Ccpd%I-+~2jlsc_|$XtL{%TizgrRqj^~!h`S=%OLdPA` z=xeNN>}p)rxT0}g;{}cC>|>sbn!l&s1K HyDt6)v7AII literal 0 HcmV?d00001 diff --git a/cv4/train b/cv4/train new file mode 100755 index 0000000000000000000000000000000000000000..b065f0d11b9310a4fa23c0a4d4bcf2b6e2a7d102 GIT binary patch literal 7946 zcmd5>e{fXA9p86%NggIS0>K&u%P9vUl}o^&D5CiZ#0EqNsKdz1%iT-v;BuF_dl!kL zBQ%1hffm#%PCFH680&QEj8mBotxmy4rF8lSTBrUY9d*P`C^$_kDl=8m&u8~-@)B^S z{ioBt+4uc^zTfYD_q+Rc_wDXI(%ibjFbttnKm-NR-u{qT3%Y-r($tEGFvWZ^S6nNK zA)>B!J8Y0;0Te2NEQB1S4!Cv)^vIRK%+%30vrH_DJX|6KGs}w#rI)g2phKRI0yiMD zUg`rN=U{&hI_42zX6ji7^D5Y{LfyEXJd<1S%fCrwsOq|S(b6KOaz&}XCSk0s9*5W*`Aj#{OR!D*Brj( z#f9%){hjFNA5e#8NgMVB%T7-8NndE5><8MAmwgwJRmpNMefQ&|5KlKMr(15Q3hmN`DBa+e(Y;zrixUmoHlC| z6sPuw%wlxrInWXmI8Ta>`-+sE{46Mf4w0hc*7u(^hhKqw$I$zi3o+RL)#&Kx&ZBP8 z@a+)xzhQ0~@;nPMy5uapjLsdwlfu!ttR+eI^oJ-mI+wL2sXKi_V%C~usHcxg%-WMx z#4k(CD3TH41Hg+u-8}G7|EZC+ZR?T|^lkFxogwq?jmh1QVlEtk!MVK?(%`JSW|Qsor8wz&k?oUv-4=-Q*s+d2G%BE<5gC5W(Etu z%~7}kE6bSD-(RK8{ftV+2kxFlqZ`)`7a^b>LkqF0_Me?Kn2y%$c_o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