Definetly very cool to do cubes with just these signs: “/”, “-” and “\”. You just have to specify the diemnsions and boulà! As always I attach you the code:
#include <iostream>
using namespace std;
void dibuixa_cub(int b, int a, int f) {
// primera part del paral·lepípede
int count = 0;
int q;
for (int i = 0; i < f; i++) cout << ” “;
for (int i = 0; i < b + 1; i++) cout << “_”;
cout << endl;
for (int i = f; i != 0; i–) {
for (int k = 0; k < i – 1; k++) cout << ” “;
for (int j = 0; j < b; j++) {
if (j == 0) cout << “/”;
if (i == 1) cout << “_”;
else cout << ” “;
if (j == b – 1) {
cout << “/”;
if (a >= f) {
count = count + 1;
if (i == f) cout << “|”;
else for (int j = 0; j < f – i; j++) {
cout << ” “;
if (j == (f – i) – 1) cout << “|”;
}
}
else {
count = count + 1;
if (count <= a) {
if (i == f) cout << “|”;
else for (int j = 0; j < f – i; j++) {
cout << ” “;
q = j;
if (j == (f – i) – 1) cout << “|”;
}
}
else {
if (a == 1) {
for (int j = 0; j < 1; j++) {
cout << ” “;
if (j == 0) cout << “/”;
}
}
else {
for (int j = 0; j <= q + 1; j++) {
cout << ” “;
if (j == q + 1) cout << “/”;
}
}
}
}
}
}
cout << endl;
}
// segona part
for (int i = a; i != 0; i–) {
for (int j = 0; j < b; j++) {
if (j == 0) cout << “|”;
if (i == 1) cout << “_”;
else cout << ” “;
if (j == b – 1) {
cout << “|”;
if (a >= f) {
if (count < a) {
if (f == 1) {
for (int r = 0; r < f; r++) {
if (r == f – 1) cout << “|”;
}
}
else {
for (int r = 0; r < f – 1; r++) {
cout << ” “;
if (r == f – 2) cout << “|”;
}
}
count = count + 1;
}
else {
for (int k = 0; k < i – 1; k++) {
cout << ” “;
if (k == i – 2) cout << “/”;
}
if (i == 1) cout << “/”;
}
}
else {
for (int k = 0; k < i – 1; k++) {
cout << ” “;
if (k == i – 2) cout << “/”;
}
if (i == 1) cout << “/”;
}
}
}
cout << endl;
}
}
int main() {
int b,a,f;
// for (int i = 1; i <= 12; i++) {
// b = i;
// for (int j = 1; j <= 12; j++) {
// a = j;
// for (int k = 1; k <= 12; k++) {
// f = k;
// dibuixa_cub(b,a,f);
// }
// }
// }
while (cin >> b >> a >> f) {
dibuixa_cub(b,a,f);
cout << endl;
}
}