# c 语言绘制坐标图像,真正实现C语言绘制数学函数图像.doc

#include

#include

int sishewuru(float a);

void main()

{

int n = 450;

float a[500], b[500];

int i,j;

a[0] = b[0] = 0;

for (i = 1; i < n; i++)

{

a[i] = a[i - 1] + 0.01;

b[i] = cos(a[i]);

}

int A[500],B[500];

for (i = 0; i < n; i++)

{

//printf("sin(%f)=%f\n", a[i], b[i]);

a[i] = 100 * a[i];

b[i] = 55 * b[i];

A[i] = sishewuru(a[i]);

B[i] = sishewuru(b[i])+60;

//printf("sin(%d)=%d\n", A[i], B[i]);

}

for ( i = 100; i >=0; i--)

{

for ( j = 0; j < n; j++)

{

if (i==B[j])

{

printf("*");

}

else

{

printf(" ");

}

}

printf("\n");

}

}

int sishewuru(float a)

{

int m;

if (a-floor(a)<0.5)

{

m = a;

return m;

}

else

{

m = a + 1;

return m;

}

}

#include

#include

int sishewuru(float a);

void main()

{

float minx = -2*3.14,

maxx = 2*3.14,dx,

x[500],y[500],k;//确定定义区间

int lx = 500, i,j, Y[500];

dx = (maxx - minx) / 450;

x[0] = minx;

y[0] = 0.1 / sin(x[1]);

for (i = 1; i

{

x[i] = x[i - 1] + dx;

y[i] =0.1/sin(x[i]);

}

k = 0.6/ dx;//扩大系数

for (i = 0; i < lx; i++)

{

Y[i] = sishewuru(k*y[i]);

//printf("%d\n", Y[i]);

}

for (i = 0; i <130; i++)

{

for (j = 0; j < lx; j++)

{

if (i == -Y[j]+65)

{

printf("*");

}

else

{

printf(" ");

}

}

printf("\n");

}

}

int sishewuru(float a)

{

int m;

if (a-floor(a)<0.5)

{

m = a;

return m;

}

else

{

m = a + 1;

return m;

}

}

#include

#include

int sishewuru(float a);

void main()

{

float minx = -2*3.14,

maxx = 2*3.14,dx,

x[500],y[2*500],k,r=0.5*maxx;//确定定义区间

int lx = 500, i,j, Y[2*500];

dx = (maxx - minx) / 450;

x[0] = minx;

y[0] = 0.1 / sin(x[1]);

for (i = 1; i

{

x[i] = x[i - 1] + dx;

y[i] =sqrt(r*r-x[i]*x[i]);//确定函数表达式

y[lx + i] = -1*y[i];

}

k =

• 0
点赞
• 0
评论
• 1
收藏
• 一键三连
• 扫一扫，分享海报

10-09

03-22 1万+
10-15 8432
05-21 3988
05-16 506
05-16 296