kiem tien, kiem tien online, kiem tien truc tuyen, kiem tien tren mang
Thứ Năm, 13 tháng 3, 2014

Thông tin về hàm Julia Set: http://en.wikipedia.org/wiki/Julia_set

Yêu cầu: Đã cài đặt Code::Blocks 10.05 và đã cấu hình đồ họa cho Code::Blocks. Nếu chưa cài đặt, bạn phải xem 2 bài viết này:
Video kết quả: bạn có thể tải mã lệnh ở bên dưới video này




Mã lệnh:

#include <graphics.h>
#include <conio.h>

#define DIM 800
float scale = 1.5;
struct comp{
float r,i;
comp(float a,float b): r(a),i(b){};
float magnitude2(){
return r*r + i*i;
}
comp operator*(const comp& a){
return comp(r*a.r-i*a.i,i*a.r+r*a.i);
}
comp operator+(const comp& a){
return comp(r+a.r,i+a.i);
}

};

int func(int i,int j){
float ji = scale*(float)(DIM/2-i)/(DIM/2);
float jj = scale*(float)(DIM/2-j)/(DIM/2);
comp c(-0.8,0.156);
comp z(ji,jj);
for(int i=0;i<200;i++){
z = z*z+c;
if (z.magnitude2()>DIM)
return 0;
}
return RED;
}
void draw(){
for(int j=0;j<DIM;j++)
for(int i=0;i<DIM;i++)
putpixel(i,j,func(i,j));

}
int main(){
initwindow(DIM,DIM);
draw();
getch();
return 0;
}
13 Mar 2014

0 nhận xét:

Đăng nhận xét

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

domain, domain name, premium domain name for sales

Bài đăng phổ biến