Last change
on this file since 00f89a6 was
7bef8cf,
checked in by Peter A. Buhr <pabuhr@…>, 19 months ago
|
start paper on llheap
|
-
Property mode set to
100644
|
File size:
541 bytes
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | |
---|
3 | typedef struct { |
---|
4 | int restart, fn1, fn; |
---|
5 | } Fib; |
---|
6 | #define FibCtor { 0, 1, 0 } |
---|
7 | |
---|
8 | Fib * comain( Fib * f ) { |
---|
9 | static void * states[] = {&&s0, &&s1}; |
---|
10 | goto *states[f->restart]; |
---|
11 | s0: f->restart = 1; |
---|
12 | for ( ;; ) { |
---|
13 | return f; |
---|
14 | s1:; int fn = f->fn + f->fn1; |
---|
15 | f->fn1 = f->fn; f->fn = fn; |
---|
16 | } |
---|
17 | } |
---|
18 | int main() { |
---|
19 | Fib f1 = FibCtor, f2 = FibCtor; |
---|
20 | for ( int i = 0; i < 10; i += 1 ) |
---|
21 | printf( "%d %d\n", comain( &f1 )->fn, comain( &f2 )->fn ); |
---|
22 | } |
---|
23 | |
---|
24 | // Local Variables: // |
---|
25 | // tab-width: 4 // |
---|
26 | // compile-command: "gcc-8 Fib3.c" // |
---|
27 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.