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

Karl Semich 0xloem at gmail.com
Tue May 24 15:14:28 PDT 2022


#include <iostream>

using namespace std;

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

  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);
      lineOf('*', width - bgratio * 2);
      lineOf(' ', bgratio);
      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();
}


More information about the cypherpunks mailing list