fork download
  1. #include <graph.h>
  2. #include <conio.h>
  3. #include <stdio.h>
  4. #include <math.h>
  5.  
  6. #define XDIM 320
  7. #define YDIM 320
  8.  
  9. float fX[XDIM + 1], fY[YDIM + 1];
  10.  
  11. void main (void)
  12. {
  13. /*
  14. ******** PROGRAM NO.1 DIGITAL BANDPASS FILTER ********
  15. */
  16.  
  17. int iCount;
  18. clearscreen (_GCLEARSCREEN);
  19. printf ("PROGRAM l: Digital bandpass fi1ter\n");
  20. printf ("Press any key to start...\n\n");
  21.  
  22. /*** GENERATE INPUT SIGNAL, AND LOAD INTO ARRAY X **/
  23.  
  24. for (iCount = 1; iCount <= XDIM; iCount++)
  25. fX[iCount] = sin (3.141593 * (float)iCount * 0.05 + 0.0005 * (f1oat)iCount));
  26.  
  27. /**** ESTIMATE OUTPUT SIGNAL OF RECURSIVE FILTER ***/
  28.  
  29. fY[l] = 0.0;
  30. fY[2] = 0.0;
  31.  
  32. for (iCount = 3; iCount <= YDIM; iCount++)
  33. fY[iCount] = 1.5 * fY[iCount - 1] - 0.85 * fY[iCount — 2] + fX[iCount];
  34.  
  35.  
  36. /**** PLOT INPUT AND 0u·1·1>UT SIGNALS ON SCREEN ******/
  37.  
  38. _setvideomode( _MRES16COLOR );
  39.  
  40. for (iCount = 1; iCount <= XDIM; iCount++)
  41. {
  42. _moveto (iCount, 50);
  43. _lineto (iCount, (int)(50.0 - fX[iCount] * 25.0 + O.5));
  44.  
  45. _moveto (iCount, 150);
  46. _lineto (iCount, (1nt)(150.0 - fY[iCount] * 4.0 + O.5));
  47. }
  48.  
  49.  
  50. _setvideomode( _DEFAULTMODE );
  51.  
  52. }
  53.  
  54.  
Success #stdin #stdout 0.01s 2280KB
stdin
Standard input is empty
stdout
Standard output is empty