author | deba |
Tue, 04 Dec 2007 14:08:27 +0000 | |
changeset 2531 | 426a4e35e167 |
parent 1956 | a055123339d5 |
child 2553 | bfced05fa852 |
permissions | -rw-r--r-- |
alpar@1847 | 1 |
/* -*- C++ -*- |
alpar@1847 | 2 |
* |
alpar@1956 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
alpar@1956 | 4 |
* |
alpar@2391 | 5 |
* Copyright (C) 2003-2007 |
alpar@1956 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
alpar@1847 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
alpar@1847 | 8 |
* |
alpar@1847 | 9 |
* Permission to use, modify and distribute this software is granted |
alpar@1847 | 10 |
* provided that this copyright notice appears in all copies. For |
alpar@1847 | 11 |
* precise terms see the accompanying LICENSE file. |
alpar@1847 | 12 |
* |
alpar@1847 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
alpar@1847 | 14 |
* express or implied, and with no claim as to its suitability for any |
alpar@1847 | 15 |
* purpose. |
alpar@1847 | 16 |
* |
alpar@1847 | 17 |
*/ |
alpar@1847 | 18 |
|
alpar@1847 | 19 |
#include <lemon/counter.h> |
alpar@1847 | 20 |
|
alpar@1847 | 21 |
///\file \brief Test cases for time_measure.h |
alpar@1847 | 22 |
/// |
alpar@1847 | 23 |
///\todo To be extended |
alpar@1847 | 24 |
|
alpar@1847 | 25 |
|
alpar@1847 | 26 |
int fibonacci(int f) |
alpar@1847 | 27 |
{ |
alpar@1847 | 28 |
static lemon::Counter count("Fibonacci steps: "); |
alpar@1847 | 29 |
count++; |
alpar@1847 | 30 |
if(f<1) return 0; |
alpar@1847 | 31 |
else if(f==1) return 1; |
alpar@1847 | 32 |
else return fibonacci(f-1)+fibonacci(f-2); |
alpar@1847 | 33 |
} |
alpar@1847 | 34 |
|
alpar@1847 | 35 |
int main() |
alpar@1847 | 36 |
{ |
alpar@1847 | 37 |
fibonacci(10); |
alpar@1847 | 38 |
|
alpar@1847 | 39 |
{ |
alpar@1847 | 40 |
typedef lemon::Counter MyCounter; |
alpar@1847 | 41 |
MyCounter c("Main counter: "); |
alpar@1847 | 42 |
c++; |
alpar@1847 | 43 |
c++; |
alpar@1847 | 44 |
MyCounter::SubCounter d(c,"Subcounter: "); |
alpar@1847 | 45 |
d++; |
alpar@1847 | 46 |
d++; |
alpar@1847 | 47 |
MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: "); |
alpar@1847 | 48 |
e++; |
alpar@1847 | 49 |
e++; |
alpar@1847 | 50 |
} |
alpar@1847 | 51 |
|
alpar@1847 | 52 |
{ |
alpar@1847 | 53 |
typedef lemon::NoCounter MyCounter; |
alpar@1847 | 54 |
MyCounter c("Main counter: "); |
alpar@1847 | 55 |
c++; |
alpar@1847 | 56 |
c++; |
alpar@1847 | 57 |
MyCounter::SubCounter d(c,"Subcounter: "); |
alpar@1847 | 58 |
d++; |
alpar@1847 | 59 |
d++; |
alpar@1847 | 60 |
MyCounter::SubCounter::SubCounter e(d,"SubSubCounter: "); |
alpar@1847 | 61 |
e++; |
alpar@1847 | 62 |
e++; |
alpar@1847 | 63 |
} |
alpar@1847 | 64 |
|
alpar@1847 | 65 |
return 0; |
alpar@1847 | 66 |
} |