高中的时候做的,前两天看了看,挺好玩的。
/***正弦函数图像***/
#include <stdio.h>
#include <math.h>
int main (void)
{
double y;
unsigned m, i;
for (y = 1; y >=0; y -= 0.1)
{
m = asin (y) * 10;
for (i = 0; i < m; i++)
putchar (' ');
putchar ('*');
for (; i < 31 - m; i++)
putchar (' ');
putchar ('*');
putchar ('\n');
}
for (y = -0.1; y >= -1; y -= 0.1)
{
m = abs(asin(y) * 10) ;
for (i = 0; i < 31 + m; i++)
putchar (' ');
putchar ('*');
for (; i < 62 - m; i++)
putchar (' ');
putchar ('*');
putchar ('\n');
}
return 0;
}
运行之后