1、周期矩形波的 C 语言代码#include#include#include#include#define pi 3.1415926#define E 2#define T1 2double function(double t);double sum();double draw();double function(double t)double x,s,w,m;int n,k;w=2*pi/T1;s=0;for(n=1;n#include#include#include#define pi 3.1415926#define E 2#define T1 2double function(doubl
2、e t);double sum();double draw();double function(double t)double x,s,w,m;int n;w=2*pi/T1;s=0;for(n=1;n#include#include#include#define pi 3.1415926#define E 2#define T1 2double function(double t);double sum();double draw();double function(double t)double x,s,w,k,m;int n;w=2*pi/T1;s=0;for(n=1;n=200;n+)
3、k=pow(-1,n-1);x=sin(n*w*t)/n*k;s=x+s;m=s*E/pi;return(m);void check_initialize()int driver,mode;detectgraph(initgraph(double sum()double c,t,m,x301,s300;int i,g,y,j;x0=0;for(i=1;i=200;i+) setcolor(5);xi=xi-1+0.02;c=xi;si=function(c);line(100*xi-1+20,-100*si-1+300,100*xi+20,-100*si+300);return 0;doubl
4、e draw()int l,b61,c60;b0=20;setcolor(9);line(10,300,600,300);line(20,310,20,30);setcolor(6);line(15,35,20,30);line(25,35,20,30);line(595,295,600,300);line(595,305,600,300);for(l=1;l=25;l+)bl=bl-1+4;cl=205;putpixel(bl,cl,5);outtextxy(10,25,“Y“);outtextxy(605,305,“X“);outtextxy(220,300,“2“);outtextxy(10,200,“1“);outtextxy(10,300,“0“);return 0;void main()check_initialize();setbkcolor(15);sum();draw();getch();