summaryrefslogtreecommitdiff
path: root/miniany/hello.c
diff options
context:
space:
mode:
Diffstat (limited to 'miniany/hello.c')
-rw-r--r--miniany/hello.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/miniany/hello.c b/miniany/hello.c
index 062ab5f..67cfe1d 100644
--- a/miniany/hello.c
+++ b/miniany/hello.c
@@ -1,8 +1,38 @@
#include <stdio.h>
+int f1(int x);
+
+int f2(int x)
+{
+ if(x==1) return 0;
+ f1(x-1);
+}
+
+int f1(int x)
+{
+ if(x==1) return 0;
+ f2(x-1);
+}
+
+int f(int x)
+{
+ if(x==0) return 0;
+ if(x==1) return 1;
+ return f(x-1)+f(x-2);
+}
+
int main()
{
- putstring("hello, world");
+ char *s;
+ s = (char *)malloc(50);
+ (void)strlcpy(s,"hello, ",50);
+ (void)strlcat(s,"world",50);
+ putstring(s);
+ putnl();
+ free(s);
+ putint(f(10));
+ putnl();
+ putint(f1(10));
putnl();
return 0;
}