实现sin(x)曲线与cos(x)曲线图形的同时显示
#include <cstdio> #include <cmath> #define PAI 32 #define AMP 10 int main(void) { int layer; double y; //ordinate of current layer int x; //abscissa of current layer int m; //abscissa of cos(x) int n; //abscissa of sin(x) for(layer=0;layer<=20;++layer) { y=0.1*layer; m=(int)(acos(1-y)*AMP); n=(int)(asin(1-y)*AMP); for(x=0;x<2*PAI;++x) { if((x==m && x==n)||(x==2*PAI-m && x==PAI-n)) printf("+"); //cross pointer else if(x==n||x==PAI-n||x==n+2*PAI) printf("+"); //on sin(x) else if(x==m||x==2*PAI-m) printf("*"); //on cos(x) else printf(" "); //blank } printf("\n");//next line } return 0; }
* + + * + + * * + + * + + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * * + * + * + * + * + * + * + * + * + * + * + * + * + * + * *+ + * * + + * * + +
posted on 2010-07-28 01:34 sohu2000000 阅读(1586) 评论(0) 编辑 收藏 举报