216k views
4 votes
Can someone please help me in answering this!?!
The language is C++

Can someone please help me in answering this!?! The language is C++-example-1
User Bobmarksie
by
7.2k points

1 Answer

2 votes

Here is a somewhat cryptic solution that works:

#include <algorithm>

#include <cstdlib>

using namespace std;

void q(char c, int count)

{

for (int i = 0; i < count; i++) {

putchar(c);

}

}

void p(int b1, int plusses)

{

q(' ', b1);

q('+', plusses);

}

int main()

{

for (int i = -3; i <= 3; i++)

{

int pl = min(6, (3 - abs(i)) * 2 + 1);

p(6-pl, pl);

i == 0 ? p(0, 6) : p(6, 0);

p(0, pl);

putchar('\\');

}

getchar();

}


User Codigomonstruo
by
7.6k points