输出倒置正弦曲线

卐结果如下图所示卐

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


 

                    *

                    |    *

                    |         *

                    |              *

                    |                 *

                    |                  *

                    |                  *

                    |                 *

                    |              *

                    |         *

                    |    *

                    *

               *    |

          *         |

     *              |

  *                 |

 *                  |

 *                  |

  *                 |

     *              |

          *         |

               *    |

                    *

请按任意键继续. . .

 

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

 

代码如下:

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


#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]http://p.blog.csdn.net/images/p_blog_csdn_net/lh3325251325/EntryImages/20091023/Snap_2009.10.23 12.41.21_002.jpg[/img]

 

 

你可能感兴趣的:(Blog,System)