2006
09-27

#include “stdio.h”
#include “stdlib.h”
#include “math.h”
#include “graphics.h”
#define fnx(x) (x0+x*s1)
#define fny(y) (y0-y*s1)
#define f(x) 0.2*(x)*(x)
void setup(void);
int x0,y0,maxx,maxy;
float s1;
main()
{
  int xs,ys;
  float x,y,x1,y1,x2,y2,dx,i;
  setup();
  x1=0;x2=5;dx=0.00001;
  clearviewport();
  setcolor(14);
  xs=fnx(x1);ys=fny(0);
  xs=fnx(x2);
  xs=fnx(0);ys=0;
  ys=fny(0);
 x=x1;y=f(x);xs=fnx(x);ys=fny(y);
  for(i=x1;i<x2;i+=dx)
    { putpixel(xs,ys,4);
      x+=dx;y=f(x);xs=fnx(x);ys=fny(y);}
      getch();
      restorecrtmode();


}
void setup(void)
{
 int driver,mode;
 driver=DETECT;
 initgraph(&driver,&mode,”");
 maxx=getmaxx();
 maxy=getmaxy();
 x0=150;y0=150;s1=10;
 setviewport(0,0,maxx,maxy,1);
}


留下一个回复