输出倒置正弦曲线

卐结果如下图所示卐

-------------------------------------俺是分割线-------------------------------------------


 

                    *

                    |    *

                    |         *

                    |              *

                    |                 *

                    |                  *

                    |                  *

                    |                 *

                    |              *

                    |         *

                    |    *

                    *

               *    |

          *         |

     *              |

  *                 |

 *                  |

 *                  |

  *                 |

     *              |

          *         |

               *    |

                    *

请按任意键继续. . .

 

-------------------------------------俺是分割线-------------------------------------------

 

代码如下:

-------------------------------------俺是分割线-------------------------------------------


#include <iostream>

#include <cmath>

#include <cstring>

 

using namespace std;

 

int main(void)

{

const double  PI=3.141592653;

double A=20.0,B=22.0;

 

char chleft,chright;

double lpos,rpos;

double y;

 

double angle=0;

 

double delta=2*PI/B;

while(angle<=2*PI)

{

y=int(A*sin(angle))+A;

if(y<A)

{

lpos=y; rpos=A;

chleft='*'; chright='|';

}

if(y==A)

{

lpos=rpos=A;

chleft='*'; chright=' ';

}

 

if(y>A)

{

lpos=A; rpos=y;

chleft='|'; chright='*';

}

 

for(int i=0;i<lpos;i++)

cout<<" ";

cout<<chleft;

for(int i=0;i<rpos-lpos-1;i++)

cout<<" ";

cout<<chright;

cout<<"/n";

 

angle+=delta;

}

 

system("pause");

 

return 0;

}

-------------------------------------俺是分割线-------------------------------------------

程序运行结果截图:
[img]https://p-blog.csdn.net/images/p_blog_csdn_net/lh3325251325/EntryImages/20091023/Snap_2009.10.23 12.41.21_002.jpg[/img]

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值