高中的时候做的,前两天看了看,挺好玩的。
/***0-360余弦函数图像***/ # include < stdio.h > # include < math.h > int main ( void ) { double y; int m, i; for ( y = 1; y >= -1; y -= 0.1 ) { m = acos(y) * 10; for ( i = 1; i < m; i++ ) { printf(" "); } printf("*"); for ( ; i < 62 - m; i++ ) { printf(" "); } printf("*\n"); } return 0; } //第二种方式 /***余弦函数图像***/ #include <stdio.h> #include <math.h> int main (void) { double m, x, y; for ( y = 1; y >= -1; y -= 0.1) { m = acos(y); for ( x = 0; x < m; x += 0.1) putchar (‘ ‘); putchar (‘*‘); for (; x < 6.2 - m; x += 0.1) putchar (‘ ‘); putchar (‘*‘); putchar (‘\n‘); } return 0; }
运行之后
时间: 2024-10-30 14:59:55