WEB开发网
开发学院软件开发C++ 用C实现exp函数 阅读

用C实现exp函数

 2008-03-08 12:52:31 来源:WEB开发网   
核心提示:#include "stdio.h"#include "stdlib.h"#include "math.h"#include "graphics.h"#define fnx(x) (x0+x*s1)#define fny(y) (y0-y*
#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);
}

Tags:实现 exp 函数

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接