Changeset 600d7be for doc/papers/concurrency/examples/Fib.c
- Timestamp:
- Jun 4, 2019, 6:28:55 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7261e3c
- Parents:
- 466fa01
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/concurrency/examples/Fib.c
r466fa01 r600d7be 1 1 #include <stdio.h> 2 2 3 #define FIB_INIT { 0, 1 } 4 typedef struct { int fn1, fn; } Fib; 3 typedef struct { 4 int fn1, fn; 5 } Fib; 6 7 #define FibCtor { 1, 0 } 8 5 9 int fib( Fib * f ) { 6 7 int ret = f->fn1; 8 f->fn1 = f->fn; 9 f->fn = ret + f->fn; 10 11 return ret; 10 int fn = f->fn; f->fn = f->fn1; 11 f->fn1 = f->fn + fn; 12 return fn; 12 13 } 13 14 int main() { 14 Fib f1 = F IB_INIT, f2 = FIB_INIT;15 Fib f1 = FibCtor, f2 = FibCtor; 15 16 for ( int i = 0; i < 10; i += 1 ) { 16 17 printf( "%d %d\n", fib( &f1 ), fib( &f2 ) );
Note: See TracChangeset
for help on using the changeset viewer.