C/C++绘制余弦曲线
#include <iostream>#include <cmath>
using namespace std;
#define COL 62 //共有63列
int main()
{
double y;//纵坐标
int x; //横坐标
int associatedX;//由y坐标计算出对应的X坐标
int i;
for (y = 1; y >= -1; y -= 0.1) //余弦值[-1:1]
{
associatedX = acos(y) * 10; //由y算出坐标X,并放大10倍
for (x = 0; x < associatedX; x++)
cout << " "; //在打印*之前,先把*前的空格打印
cout <<"*"; //打印左侧的*
for (; x < COL-associatedX; x++)
cout << " "; //打印从左侧的*开始到右侧*之前的空格
cout << "*";
cout << endl; //在同一行上打印两个*之后换到下一行
}
}
最后更新:2017-04-02 18:30:40
上一篇:
Android创建和删除桌面快捷方式
下一篇:
Android中shape的使用
智能家居——IoT零基础入门篇
LAMP编译:usr bin ld cannot find lltdl 错误的解决办法
300+篇运维、数据库等实战资料免费下载(文章+PDF+视频,持续更新)
[原创](2010.02.07更新)忙里偷闲中写的一个系统物理/虚拟内存查看器。
杭州公交云:市政公共服务在互联网的新尝试
25 个让 Java 程序员更高效的 Eclipse 插件
Uber前高管成立新地图公司,为自动驾驶提供路线服务
收藏个博客 爪哇米工作室陈跃峰的移动开发博客
Mobile UI Design Patterns: 10+ Sites for Inspiration
还是找程序员做老公,最靠谱!