| 導購 | 订阅 | 在线投稿
分享
 
 
 

用C實現exp函數!

來源:互聯網網民  2008-06-01 01:21:01  評論

#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);

}

 
特别声明:以上内容(如有图片或视频亦包括在内)为网络用户发布,本站仅提供信息存储服务。
 
#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); }
󰈣󰈤
王朝萬家燈火計劃
期待原創作者加盟
 
 
 
>>返回首頁<<
 
 
 
 
 
 熱帖排行
 
 
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有