From 06c80fcd6830686c8cde6ba11c252ecd5c0908ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C3=B1o=20Sempere?= Date: Sat, 7 Apr 2018 15:43:16 +0200 Subject: [PATCH] Add files via upload --- divisor 1.0/const.h | 9 +++++ divisor 1.0/main | Bin 0 -> 19528 bytes divisor 1.0/main.c | 48 ++++++++++++++++++++++++ divisor 1.0/states.h | 6 +++ divisor 1.0/states.o | Bin 0 -> 2576 bytes divisor 1.0/turing.c | 86 +++++++++++++++++++++++++++++++++++++++++++ divisor 1.0/turing.h | 8 ++++ 7 files changed, 157 insertions(+) create mode 100644 divisor 1.0/const.h create mode 100644 divisor 1.0/main create mode 100644 divisor 1.0/main.c create mode 100644 divisor 1.0/states.h create mode 100644 divisor 1.0/states.o create mode 100644 divisor 1.0/turing.c create mode 100644 divisor 1.0/turing.h diff --git a/divisor 1.0/const.h b/divisor 1.0/const.h new file mode 100644 index 0000000..b0babc6 --- /dev/null +++ b/divisor 1.0/const.h @@ -0,0 +1,9 @@ +#ifndef __CONST_H_ +#define __CONST_H_ + +#define REJECT -1 +#define ACCEPT -2 + +#endif + + diff --git a/divisor 1.0/main b/divisor 1.0/main new file mode 100644 index 0000000000000000000000000000000000000000..5cc81b3206eca5649f0fb7e6a1cd594802af5178 GIT binary patch literal 19528 zcmeHPdvsLQx!-3_9%nLP5)x2ATaE>;=rxmofcSz5WN@NEC?q!3;>l!Yl8h!Zx$~f) zwW3kWG*UxvTUqN;(AMj<4_kVd_F7N~g=J`Kue7zj+*Q`P(TWYF4_Y5htCIWs_G5D9 zWa4$T*4{rjFz4IfbAS8W`#Wdvea^|9fu>b1O=IeCv1N>~$`U^(i8Eutl^m6{rOeIz zY%aTim4H%=pPzFGijsn((zJqxl+yu=@LTE%_CvnU( z3H_o;=+{p|Uo{E64RjMf=dm1wLjHUR^r>tXYct!piW)yO?up*(pfkihOkrNaEGv}` zg>SXOUAI~tp;$Ldr6aL8ofDZf>*&p-!;p!k65-1)w>n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N;@U; zK9k0{NhPeVP&|Ub@C6fnifz%V!8tj$g_!yYuC%98vMT-sHt&3_p|0I%t&<~kWp^l* z!tmrQ*~&WkEw|Gz^pP4a)Ol)<=XD+PVQq#vKVUj3V3#UkeG*OfGG82vEMNVK#+r1f zQ)1X7^0jAT_~t(rVLrmTLa8q1i)@a=o`6`WaLz`o4Dmfi9%6x)jCO}eL6&;E)6B=? z;6u^ZnE;xmrI?TM2|@|p=e}r{%%H9aj3`W~ic}IBs(ecrVyGt66AQzKM4HTlLIcQ$ zfHNPGnikfeMcXr-&mnT{KaZc({YFt1pkUWm>#elZpQ{8Vbm}*Nj?YdK zQaraV+aU?_rCzaw*jCRwt_Ow<@tpsIEFu|nX-4LIxgsruDA zZx0c1&>JfD!x_Ju!K8Pxl)hRI`ej3>NoD1~l2hPeW(AD%xJz% zqDo(_FLy}&pcGW~JKKMc)L$Xx)H-xn>JQlTDP~Un&wxfTA^+%5>(yRa;VePUou%0v zo<+&7uhz8#Qs22NP$@MP{G3CdmH35(bV&It)pGtT{EH~q>sRxhN~zyYFKyTkRj(p_ z83nt(T2H5?pj!z_=xjed2q%5je`;R0Me5fO({?!9^DXe~`s(k!sJ{bqzfG5l&iW5H z^!-(S62p3)gWTVt5!iVDEBt#XV0OuKh-m7)P4#zSoc=oTpF*d?rmyw|X2>P8Q{IWc z2wiHwOxN5x*nF4zuRxc&TIs8O2K9G)j>`DU;gB0YY8>ov)UWm94{S{GCHT zw{KyBfg>nD?yU3_90kYTezoohnnFeSsSGGRg`YuzXsZ2fW*cX3n$V4 z?Il9#gi1_l!>PY`68)dl3WZJ;*h%#3rM@$MS6nI-W=*26{Fn+chX_}Eyi$XBw?g#~FBAIH9ZZKi?0*5!ATgQ% literal 0 HcmV?d00001 diff --git a/divisor 1.0/main.c b/divisor 1.0/main.c new file mode 100644 index 0000000..fb1ac54 --- /dev/null +++ b/divisor 1.0/main.c @@ -0,0 +1,48 @@ +#include +#include +#include "turing.h" +#include "states.h" +#include "const.h" + +#define REJECT -1 +#define ACCEPT -2 + +// gcc -g main.c turing.c states.c turing.h states.h const.h -o main + +int main(){ + + int List[] = {0,1,8,2,2,9}; + int longitud=length(List); + + fprintf(stdout,"\nEsta función acepta cuando n no divide a m."); + + int state=0; + int position=0; + int symbol= List[position]; + int movement =0; // undefined. + int placeholder; + + + while(state!=ACCEPT && state!=REJECT){ + + print_linea(); + print_variables(state,position,symbol, movement); + print_lista(List, longitud, position); + + fscanf(stdin,"\n%d", &placeholder); + + carry_out_step(&symbol,&state,&movement); + + List[position]=symbol; + position = position +movement; + symbol=List[position]; + + } + + print_linea(); + print_variables(state,position,symbol, movement); + print_lista(List, longitud, position); + + + +} diff --git a/divisor 1.0/states.h b/divisor 1.0/states.h new file mode 100644 index 0000000..625b918 --- /dev/null +++ b/divisor 1.0/states.h @@ -0,0 +1,6 @@ +#ifndef __STATES_H_ +#define __STATES_H_ + +void carry_out_step(int *symbol, int *state, int *movement); // This is the only function I'm going to need to use outside of states.c + +#endif diff --git a/divisor 1.0/states.o b/divisor 1.0/states.o new file mode 100644 index 0000000000000000000000000000000000000000..1e33186fbb83ecb042c3b8d3801d7260980bfe15 GIT binary patch literal 2576 zcmbtV&ubG=5T0$UHfgI>R0I`+TB)E*VzpRBiI%mCh)6NiTi7-mTQrGm-eUa?7KIoK zf|nk>dG)9sv?^M}gFW=ne?YLIZvtE@fA*%~bvAYIZ7b*Os++AjPg)^XUnD^x6!F zrkXW<(3-ls&8{_)w_SblbRCY*DAsdAK2kU9;Cj-Uqxq!uIgVDCw7$mUZ>(<`pG_mD zX3e3Tzgf$TWj{Y7C%ZcNm`16FBzxQ*TYF1BsaZ3&F;#4G<05|C)GTuD%WTJ~pT-!J?2d;*}ir{_SjBRk-igrD4J?ln`pyL`Dy zUr%?Lsl8_R&HzvDNu|3|U8!z5jgE_m4+0Sn&r&Kn$Yy8w2(+DNoEK ztYQ0xx)Bd=MKZU&i#;%&hrDt=Q^($-ik4G{*x*`<$>BSGb@*h!WjUwBD`Q6 z(lgIJ@0h|J5n$#W;ea_%setK~gT-LESak6sGD~IQn!P8pyJZz3f!y4oT)}gS?yori zIZ2{Fy;}GS%^*gmzsq11aP^$Vjo9e+$YA4^QCCWvN($9J#nCs!21VYX@bJyl{97^= zS#cLv0K0HOn*ZvbR+`~(I{rQ$OmR6xmpi>zii0@MD8YLEs+{1c@(;O#AKs86Xg|&G zSN>u8hywO&q8fGnHQa}jsPj9e3PPU~ogevXe~qt3ES!6UU`Y8pv|twAKdr-iC;B4= ao>C6 +#include +#include "turing.h" +#include "const.h" + +// Turing print defines functions that take a list, take a position in that list and print the list with a pointer to that position. +// It prints this vertically + +int length(int *List){ + int i =0; + + while (List[i]<9){ // Por cómo construimos nuestras listas. + i=i+1; + } + + /*Anecdóticamente, el siguiente código da error. + i=0; + while (List[i]<=9){ + i=i+1; + } + Y lo hace porque al asignar un trozo de memoria, + si la lista tiene, p.ej., longitud 6, + List[0] hasta Lista[5] son la lista de verdad, + pero Lista[6] <9, y la sigue contando. + */ + + fprintf(stdout, "%d",i+1); + return i+1; +} + +void print_lista(int*L, int length, int position){ + if(L==NULL || length <= position){ + fprintf(stdout, "\nError en prettyprint"); + } + else{ + int i=0; + char tabs[]="\t\t\t\t\t\t\t\0"; + for(i=0; i