1、周期矩形波周期锯齿波周期三角波C语言程序 集团文件发布号:(9816-UATWW-MWUB-WUNN-INNUL-DQQTY-19882)周期矩形波周期锯齿波周期三角波C语言程序周期矩形波的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
2、=1;n=200;n+) k=pow(-1,n-1); x=cos(2*n-1)*w*t)/(2*n-1)*k; s=x+s; m=s*2*E/pi; return(m); void check_initialize()int driver,mode;detectgraph(&driver,&mode);initgraph(&driver,&mode,.bgi);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=functio
3、n(c); line(100*xi-1+20,-100*si-1+300,100*xi+20,-100*si+300); return 0;double draw() int l,b61,c60; b0=200; setcolor(9); line(10,300,600,300); line(20,410,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=220; putpi
4、xel(cl,bl,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();周期三角波C语言代码#include#include#include#include#define pi 3.1415926#define E 2#define T1 2double function
5、(double 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=200;n+) x=cos(2*n-1)*w*t)/(2*n-1)*(2*n-1); s=x+s; m=s*4*E/(pi*pi)+E/2; return(m); void check_initialize()int driver,mode;detectgraph(&driver,&mode);initgraph(&driver,&mode,.bgi);double su
6、m() 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+400,100*xi+20,-100*si+400); return 0;double draw() int l,b61,c60; b0=200; setcolor(9); line(10,400,600,400); line(20,410,20,30); setcolor(6); line(15,35,20,30);
7、 line(25,35,20,30); line(595,395,600,400); line(595,405,600,400); for(l=1;l=50;l+) bl=bl-1+4; cl=220; putpixel(cl,bl,5); outtextxy(10,25,Y); outtextxy(605,405,X); outtextxy(220,400,2); outtextxy(10,200,2); outtextxy(10,400,0); return 0;void main() check_initialize(); setbkcolor(15); sum(); draw(); g
8、etch();周期锯齿波的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,k,m; int n; w=2*pi/T1; s=0; for(n=1;n=200;n+) k=pow(-1,n-1); x=sin(n*w*t)/n*k; s=x+s; m=s*E/pi; return(m); void che
9、ck_initialize()int driver,mode;detectgraph(&driver,&mode);initgraph(&driver,&mode,.bgi);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;double draw() int l,b61,c6
10、0; 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();
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1