/**
* 【程序4】
* 题目:用星号绘制余弦曲线和直线。
*/
#include <stdio.h>
#include <math.h>
int main() {
double y;
int xc;
int xx;
int xl;
for (y = 1; y >= -1; y -= 0.1) {
xc = acos(y) * 10;
xl = 45 * (y - 1) + 31;
for (xx = 0; xx <= 62; xx++) {
if (xx == xl) { //有两种情况一个是xx == xl && xx == xc还有一个是xx == xl && xx != xc
printf("+");
} else if (xx == xc || xx == 62 - xc) { //cos以31对称
printf("*");
} else {
printf(" ");
}
}
printf("\n");
}
return 0;
}