home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / FALKMAG / FKM_07_2.ZIP / WOBLER.S / TAB_1.C < prev    next >
C/C++ Source or Header  |  1997-04-28  |  747b  |  38 lines

  1. /* générateur de fichier DAT contenant une fonction mathématique */
  2. /* par Golio Junior */
  3.  
  4. #include <stdio.h>
  5. #include <math.h>
  6.  
  7. #define X_MIN    0
  8. #define X_MAX    M_PI*8
  9.  
  10. #define TAILLE_TABLEAU    256
  11.  
  12. /* nom du fichier créé */
  13. static char nom[]="dat1.dat";
  14.  
  15. int fonction(float x)
  16. { return (int)(100+cos(x)*50);
  17. }
  18.  
  19. int main(void)
  20. { int i, y;
  21.   float x;
  22.   FILE *fichier;
  23.  
  24.   if ((fichier=fopen(nom, "w"))==NULL)
  25.       { printf(" Impossible d'ouvrir le fichier %s \n",nom);
  26.         return -1;
  27.       }
  28.       else
  29.       { /* routine de generation */
  30.       for (i=0; i<TAILLE_TABLEAU; i++)
  31.         { x=i*(X_MAX-X_MIN)/TAILLE_TABLEAU;
  32.           y=fonction(x);
  33.           fprintf(fichier, "\tdc.w $%X\n", y);
  34.         }
  35.       fclose(fichier);
  36.     }
  37.   return 0;
  38. }