c作图-正弦函数图像

#include<graphics.h>
#include<math.h>
int main()
{
    int gmode,gdriver=DETECT;
 double x1,y1,x2,y2;
    initgraph(&gdriver,&gmode,"");
    cleardevice();
 setbkcolor(WHITE);
 setcolor(BLACK);
    line(0,240,600,240);
    line(570,220,600,240);
 line(570,260,600,240);
    line(320,0,320,480);
    line(300,35,320,0);
    line(340,35,320,0);
   for(x2=100;x2<=540;x2+=0.001)
 {
  y2=-sin(((x2+40)-360)/70)*100+240;
  if(x2!=100)
  {
   setcolor(RED);
   //line(x1,y1,x2,y2);
  // putpixel(x2,y2,RED);
  }
  x1=x2;
  y1=y2;
 }
   getch();
   return 0;
}

posted @ 2018-04-11 16:38  sdibt布谷鸟  阅读(370)  评论(0编辑  收藏  举报