From 2089ceee1858860db74c35de91be6a50863c01cb Mon Sep 17 00:00:00 2001 From: Radovan Kofira Date: Sat, 9 Jan 2021 20:33:08 +0100 Subject: [PATCH] hotovo --- sk4/kod.txt | 18 +++++--- sk4/program.c | 116 ++++++++++++++++++++++++++++++++---------------- sk4/program.exe | Bin 48101 -> 47522 bytes 3 files changed, 91 insertions(+), 43 deletions(-) diff --git a/sk4/kod.txt b/sk4/kod.txt index 6df31d6..79e3bae 100644 --- a/sk4/kod.txt +++ b/sk4/kod.txt @@ -1,7 +1,15 @@ TUK -INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK KUK -DEK DEK KUK -DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK KUK -KUK -DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK KUK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +INK INK INK PUK +INK INK INK INK INK INK INK INK INK INK INK PUK +BREK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +GLEK +DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK PUK +INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK INK PUK +DEK DEK DEK DEK DEK DEK DEK DEK DEK PUK 102 +INK INK INK PUK 105 +INK INK INK INK INK INK INK INK INK PUK 114 +DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK DEK PUK 97 FUK \ No newline at end of file diff --git a/sk4/program.c b/sk4/program.c index 221733e..fcb748b 100644 --- a/sk4/program.c +++ b/sk4/program.c @@ -13,18 +13,20 @@ TUK, FUK char dtape[30000] = {0};//hlava dh inst ptape[30000] = {0};//hlava ph -size_t loops[2][15000] = {{0},{0}}; +size_t validRP[15000]={0}; + +inst* loops[2][15000] = {{0},{0}};//adresy zatvoriek size_t loopscount=0; char* dhead = dtape; inst* phead = ptape; -void run_tukafuk(const char* code) {// +void run_tukafuk(const char* code) { char current_char; bool running = false; size_t i; //bolo pozadovane zistit, kdd su skoky a teda som ich ulozil //(tie adresy skokov) - for (i = 0; code[i] != 0; i++) { + for (i = 0; code[i] != 0; i++){ current_char = code[i]; size_t j; size_t loop; @@ -97,8 +99,9 @@ void run_tukafuk(const char* code) {// break; case ']': for(size_t k=0;k - ++ptr; - } else if (current_char == 'DEK') {//< - --ptr; - } else if (current_char == 'BREK') {// + - ++*ptr; - } else if (current_char == 'GLEK') {// - - --*ptr; - } else if (current_char == 'PUK' ) {// . - putchar(*ptr); - } else if (current_char == 'KUK') {// , - *ptr = getchar(); - } else if (current_char == '[') {//start loop - continue; - } else if (current_char == ']' && *ptr) {stop loop - loop = 1; - while (loop > 0) { - current_char = input[--i]; - if (current_char == '[') { - loop--; - } else if (current_char == ']') { - loop++; - } - */ } + phead = ptape; + for (i = 0; i<30000; i++){ + if(running){ + switch(*phead){ + case INK: + (*dhead)++; + break; + case DEK: + (*dhead)--; + //printf("->%c\n",*dhead); + break; + case BREK: + dhead++; + break; + case GLEK: + dhead--; + break; + case PUK: + //printf("Puk\n"); + putchar(*dhead); + //printf("\nPukEnd\n"); + break; + case KUK: + printf("Zadaj vstup: \n"); + *dhead=getchar(); + //printf("Kukol %c\n",*dhead); + break; + case FUK: + running=false; + break; + case LP: + if(*dhead==0){ + for(int j=0;j^4=eUuGC>YJ4AU4Ly8r#?sK{PfT zG%t*x_{gl8pg4|6oP-Dw$2c=g#@S6G$&d`0Gy}=76DD!hncly;@9pNwe!Jg(-+r^r zcj{FAbX;a z`Oqgqd`voOgFZ%c#Kje4v&GMU~~KPvo= z9;j1>)lYTyqnp{gXpSZ=>Tw{}n~t8}{oUahWB~zW_D7~twI)PR(-}>?<=?nqpW3bp zV5}i9$H*$x276iv#Fk;WhV_*uR^C#!*lvMbRcHto2(*t2f>L+Cea|q+ZRI_zGTq?Q z!1kgW{x+z21%{r&0#vrzXF{Yh(qO;IMaQ&Mo19XoU~LMknjgp|`=>~was8_KNgV4` zVmTbULC<k6u2t8kIqThRsF@ZDtE13A)JjpZZi2qQIjVj4nP87w%Jeor7@_ zxL^wH_b#(=+42^%KX>*INlyJ=wAySKz}h$cy6Jn?ZtCY=^|YuEj8#5WrhcJAdzn?3 z?r7gJ-LcvqwcZ`AJ@6{;RhO@XaYq+q4(A9}CLgEd>{Z(GO}v|N=~|7WF9(Sxx<7&tzH8V=YTt9x0;=YhFMlW8C4P#=aCKCp^YXBemrp%CN%P zRSNVSV}T2=$lV^T<=XNJ8TBZcwB@BTsv11aT%eL;s10#U)iX<0^9+%xEuSDFIu8X6 zV+6^PC|3Za&IpnEJ~SqzUs~(^;)r z)&11E1n$b@w8wLd!PB9Y4@*0%@q#p$iCVG(|CZ@YgMn6UhmD3Cd2l(m`&}bPN&6$DpRLRdyrXJ9RYl>!QNo2sT1}(Wqa*dTdn1? z>3eIx0E0ojiSDral&LWjL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