资源描述:
《周期矩形波、周期锯齿波、周期三角波,C语言程序》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用文档周期矩形波的C语言代码#include#include#include#include#definepi3.1415926#defineE2#defineT12doublefunction(doublet);doublesum();doubledraw();doublefunction(doublet){doublex,s,w,m;intn,k;w=2*pi/T1;s=0;for(n=1;n<=200;n++){k=pow(-1,n-1);x=cos((2*
2、n-1)*w*t)/(2*n-1)*k;文案大全实用文档s=x+s;}m=s*2*E/pi;return(m);}voidcheck_initialize(){intdriver,mode;detectgraph(&driver,&mode);initgraph(&driver,&mode,"..\bgi");}doublesum(){doublec,t,m,x[301],s[300];inti,g,y,j;x[0]=0;for(i=1;i<=200;i++){setcolor(5);x[i]=x[i-1]+0.02;c=x[i];s[i
3、]=function(c);line(100*x[i-1]+20,-100*s[i-1]+300,100*x[i]+20,-100*s[i]+300);}文案大全实用文档return0;}doubledraw(){intl,b[61],c[60];b[0]=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,3
4、00);for(l=1;l<=25;l++){b[l]=b[l-1]+4;c[l]=220;putpixel(c[l],b[l],5);}outtextxy(10,25,"Y");outtextxy(605,305,"X");文案大全实用文档outtextxy(220,300,"2");outtextxy(10,200,"1");outtextxy(10,300,"0");return0;}voidmain(){check_initialize();setbkcolor(15);sum();draw();getch();}文案大全实用文档周
5、期三角波C语言代码#include#include#include#include#definepi3.1415926#defineE2#defineT12doublefunction(doublet);doublesum();doubledraw();doublefunction(doublet){doublex,s,w,m;intn;w=2*pi/T1;s=0;for(n=1;n<=200;n++){x=cos((2*n-1)*w*t)/((2*n-1)*(2*
6、n-1));s=x+s;}m=s*4*E/(pi*pi)+E/2;文案大全实用文档return(m);}voidcheck_initialize(){intdriver,mode;detectgraph(&driver,&mode);initgraph(&driver,&mode,"..\bgi");}doublesum(){doublec,t,m,x[301],s[300];inti,g,y,j;x[0]=0;for(i=1;i<=200;i++){setcolor(5);x[i]=x[i-1]+0.02;c=x[i];s[i]=fun
7、ction(c);line(100*x[i-1]+20,-100*s[i-1]+400,100*x[i]+20,-100*s[i]+400);}return0;}doubledraw()文案大全实用文档{intl,b[61],c[60];b[0]=200;setcolor(9);line(10,400,600,400);line(20,410,20,30);setcolor(6);line(15,35,20,30);line(25,35,20,30);line(595,395,600,400);line(595,405,600,400);f
8、or(l=1;l<=50;l++){b[l]=b[l-1]+4;c[l]=220;putpixel(c[l],b[l],5);}outtextxy(10,25,"Y");outt