# HG changeset patch # User Nobuyasu Oshiro # Date 1344334390 -32400 # Node ID 42f3a796c0bec036c29cecf47215f715103a90e1 # Parent 12fe1bbe8b4fbf144b516fe92a8c069dd2c72887 add dynamic-fibonacci.cbc diff -r 12fe1bbe8b4f -r 42f3a796c0be Huffman/test-huffman.c --- a/Huffman/test-huffman.c Wed Aug 01 19:36:27 2012 +0900 +++ b/Huffman/test-huffman.c Tue Aug 07 19:13:10 2012 +0900 @@ -65,21 +65,46 @@ quick_sort(numbers, N); +/* int node[2*N]; int node_count = 0; int *prev_node; for (i=0; i<2*N; i++) node[i] = 0; +*/ + + struct node { + int cost; + int *p; + struct node *parent, *l_child, *r_child; + }; + + struct node nodes[N]; + nodes = malloc(sizeof(struct node)*N); + int node_count = 0; + + // initialization of nodes + for (i=0; i +#include + +__code print(int result) +{ + printf("result = %d\n",result); + exit(0); +} + +__code fibonacci1(int result, int num1, int num2, int loop) +{ + + if (loop < 2) goto print(result); + result = num1 + num2; + num1 = num2; + num2 = result; + + loop--; + goto fibonacci1(result, num1, num2, loop); +} + + +__code fibonacci(n) +{ + goto fibonacci1(0, 0, 1, n); +} + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + printf("usage: ./fibonacci number \n"); + exit(0); + } + int n = atoi(argv[1]); + goto fibonacci(n); + + return 0; +}