在屏幕上用“*”显示0~360度的余弦函数cos(x)曲线 #include <stdio.h> #include <math.h> #define WIDE 62 int main(void) { double y, m; int x; for(y=1;y>=-1;y-=0.1) { m = acos(y)*10; for(x=1;x<m;++x) printf(" "); printf("*"); for(;x<(WIDE-m);++x) printf(" "); printf("*"); printf("/n"); } return 0; } Output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **