[ot][spam][crazy][crazy][spam]
Karl Semich
0xloem at gmail.com
Tue May 24 15:16:22 PDT 2022
i think i'm familiar with it being hollow
#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(' ', 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();
}
More information about the cypherpunks
mailing list