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