/* Automatically generated by the nanoLang compiler ncc. The bolierplate and library code is released under the GNU General Public Licence, version 2 or, at your choice, any later version. Other code is governed by the license of the original source code. */ #include #include #include typedef long long N_Integer; typedef char* N_String; #define NANO_MAKESTR(s) s #define NANO_STRASSIGN(l, r) (l) = (r) #define NANO_STRVAL(s) s /* Global user variables */ /* Function declarations */ N_Integer n_Exit(N_Integer); N_Integer n_StrIsInt(N_String); N_Integer n_StrToInt(N_String); N_Integer n_StrLen(N_String); N_String n_IntToStr(N_Integer); N_String n_StrFront(N_String,N_Integer); N_String n_StrRest(N_String,N_Integer); N_String n_StrCat(N_String,N_String); N_Integer n_StrToASCII(N_String); N_String n_ASCIIToStr(N_Integer); N_Integer n_fibrek(N_Integer); N_Integer n_fibit(N_Integer); N_Integer n_main(); /* nanoLang runtime library code */ /* String functions */ N_String n_StrCat(N_String arg1, N_String arg2) { size_t len = strlen(arg1)+strlen(arg2)+1; char *res = malloc(len); strcpy(res, arg1); strcat(res, arg2); return res; } N_Integer n_StrIsInt(N_String str) { char *err=NULL; if(!str[0]) { return 0; } strtoll(str, &err, 10); if(*err == 0) { return 1; } return 0; } N_Integer n_StrToInt(N_String str) { N_Integer res = strtoll(str, NULL, 10); return res; } N_Integer n_Exit(N_Integer ret) { exit(ret); } N_String n_IntToStr(N_Integer val) { char buff[30]; sprintf(buff, "%lld", val); return strdup(buff); } /* User function definitions */ N_Integer n_fibrek(N_Integer n_n) { if((n_n)<=(1)) { return (1); } return ((n_fibrek(((n_n)-(1))))+(n_fibrek(((n_n)-(2))))); } N_Integer n_fibit(N_Integer n_n) { N_Integer n_tmp = 0; N_Integer n_f0 = 0; N_Integer n_f1 = 0; n_f0 = (1); n_f1 = (1); while((n_n)>(0)) { n_tmp = ((n_f1)+(n_f0)); n_f0 = (n_f1); n_f1 = (n_tmp); n_n = ((n_n)-(1)); } return (n_f0); } N_Integer n_main() { printf("%s",NANO_STRVAL((NANO_MAKESTR("Rekursiv: ")))); printf("%lld",(n_fibrek((10)))); printf("%s",NANO_STRVAL((NANO_MAKESTR("\nIterativ: ")))); printf("%lld",(n_fibit((10)))); printf("%s",NANO_STRVAL((NANO_MAKESTR("\n")))); return (0); } /* C main function */ int main(int argc, char* argv[]) { return n_main(); }