fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4.  
  5. const long double Pi {3.1415926535897932384626433};
  6. const long double RadConvDeg {Pi/180.0}; //multiply RtL, divide LtR
  7.  
  8. int main()
  9. {
  10. using str = std::string;
  11. using st = str::size_type;
  12. for(st i {0}; i < 180; i += 4)
  13. {
  14. std::cout << str(static_cast<st>(std::sin(RadConvDeg*i)*80.0), ' ') << '*' << std::endl;
  15. }
  16. }
  17.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
*
     *
           *
                *
                      *
                           *
                                *
                                     *
                                          *
                                               *
                                                   *
                                                       *
                                                           *
                                                               *
                                                                  *
                                                                     *
                                                                       *
                                                                          *
                                                                            *
                                                                             *
                                                                              *
                                                                               *
                                                                               *
                                                                               *
                                                                               *
                                                                              *
                                                                             *
                                                                            *
                                                                          *
                                                                       *
                                                                     *
                                                                  *
                                                               *
                                                           *
                                                       *
                                                   *
                                               *
                                          *
                                     *
                                *
                           *
                      *
                *
           *
     *