Changeset 115 for trunk/Softwares


Ignore:
Timestamp:
Apr 20, 2009, 11:29:17 PM (15 years ago)
Author:
rosiere
Message:

1) Write queue with mealy
2) Network : fix bug
3) leak memory

Location:
trunk/Softwares
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Softwares/Common/src/c/func_factoriel.c

    r108 r115  
    55//-----[ Factoriel ]-------------------------------------------------------
    66
     7#define mul(x,y) mul_soft(x,y)
     8
    79unsigned int factoriel_recursif (unsigned int x)
    810{
     
    1012    return 1;
    1113
    12   unsigned int res = mul_soft (x , factoriel_recursif (x-1));
     14  unsigned int res = mul(x , factoriel_recursif (x-1));
    1315 
    1416  return res;
     
    2123  while (x > 1)
    2224    {
    23       res = mul_soft(res,x);
     25      res = mul(res,x);
    2426      x --;
    2527    }
  • trunk/Softwares/Test/Test_099/src/c/main.c

    r102 r115  
    1313#include "func_io.h"
    1414
     15#define mul(x,y) x*y
     16
     17unsigned int f1 (unsigned int x)
     18{
     19  if ( x <= 1)
     20    return 1;
     21
     22  unsigned int res = mul (x , f1 (x-1));
     23 
     24  return res;
     25}
     26
     27unsigned int f2 (unsigned int x)
     28{
     29  unsigned int res= 1;
     30 
     31  while (x > 1)
     32    {
     33      res = mul(res,x);
     34      x --;
     35    }
     36  return res;
     37}
     38
    1539int main()
    1640{
    17   test_mul_soft           ();
    18   test_div_soft           ();
    19   test_modulo             ();
    20   test_fibonnacci         (30);
    21   test_n_premier          (6);
    22   test_factoriel_iteratif (12);
    23   test_factoriel_recursif (12);
    24    
     41  for (int i=0; i<500; ++i)
     42    if (f2 (12) != 479001600) quit(i);
    2543  quit(0);
    2644}
Note: See TracChangeset for help on using the changeset viewer.