[ot][spam][crazy][crazy][spam]

Karl Semich 0xloem at gmail.com
Wed May 25 11:53:29 PDT 2022


#include <iostream>

using namespace std;

class Triangle
{
public:
  Triangle(int width, int height)
  : width(width), height(height / 2)
  {  }

  void draw()
  {
    int start_offset = width / 2;
    int end_offset = 0;
    for (int row = 0; row < height; ++ row) {
      int bgratio = (end_offset - start_offset) * row / height +
start_offset;
      lineOf(' ', bgratio - 1);
      cout << '*';
      lineOf(row + 1 < height ? ' ' : '*', width - bgratio * 2);
      cout << '*' << endl;
    }
  }

private:
  int width, height;

  void lineOf(char ch, int count)
  {
    for(; count; -- count)
      cout << ch;
  }
};

int main()
{
  Triangle triangle(16,16);
  triangle.draw();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/html
Size: 1088 bytes
Desc: not available
URL: <https://lists.cpunks.org/pipermail/cypherpunks/attachments/20220525/8afdd63d/attachment.txt>


More information about the cypherpunks mailing list