绘制正弦曲线
如何实现用“*”显示0~360度的sin(x)曲线
#include <stdio.h> #include <math.h> #define PERIODE 64 #define HALF 32 #define QUARTER 16 #define ENLARGE 10 #define YMAX 1 #define YMIN -1 int main(void) { double y,m; int x; for(y=YMAX; y>0; y-=0.1) { m = asin(y)*ENLARGE; for(x=1;x<m; ++x) printf(" "); printf("*"); for( ;x<(HALF-m); ++x) printf(" "); printf("*\n"); } for(y=0.1; y<=YMAX; y+=0.1) { m = asin(y)*ENLARGE; for(x=1;x<(HALF+m); ++x) printf(" "); printf("*"); for( ;x<(PERIODE-m);++x) printf(" "); printf("*\n"); } return 0; }
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
posted on 2010-07-27 10:58 sohu2000000 阅读(382) 评论(0) 编辑 收藏 举报