📄 7iv.cpp
字号:
// drawcos.cpp Plot the cosine function horizontally on the
// screen for angles from 0 to 3p.
#include <iostream.h>
#include <math.h>
// PlotPoint () Plot the cosine of the angle parameter
// on a line across the screen
// IN: angle -- the angle in radians to be plotted
void PlotPoint (float angle)
{ int blanks, position;
position = cos (angle) * 35 + 35;
for (blanks=0; blanks<position; blanks=blanks+1)
cout << " ";
cout << "*" << endl;
}
// PlotYAxis() draw a Y axis and fiducial marks on screen
void PlotYAxis()
{ cout << " -1.0 0.0 1.0" << endl;
cout << "--------------------------|----------------------" << endl;
}
void main ()
{ float angle;
const float anglestep = 0.1885; // 3p / 50
const float limit = 9.42478; // 3p
PlotYAxis(); // draw the Y axis
// plot a point for each angle from 0 to 3p in steps of 3p/50
for (angle=0.0; angle<limit; angle=angle+anglestep)
PlotPoint (angle);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -