How to draw a simple cuboid using plain ASCII art in C++

2 Answers

0 votes
#include <iostream>

using std::cout;
using std::endl;

int main() {

    // ---------------------------------------------------------
    //   Draw a simple cuboid using ASCII characters
    //   This is NOT 3D rendering — just a text illustration
    // ---------------------------------------------------------

    cout << "  +--------+" << endl;   // top face
    cout << " /        /|" << endl;   // top-left edge
    cout << "+--------+ |" << endl;   // top-right edge
    cout << "|        | +" << endl;   // right vertical edge
    cout << "|        |/" << endl;    // right-bottom edge
    cout << "+--------+" << endl;     // bottom face
}



/*
run:

  +--------+
 /        /|
+--------+ |
|        | +
|        |/
+--------+

*/

 



answered 22 hours ago by avibootz
0 votes
#include <iostream>

using std::cout;
using std::endl;

int main() {

    // ---------------------------------------------------------
    //   A cleaner, more proportional cuboid
    // ---------------------------------------------------------

    cout << "     +----------+" << endl;
    cout << "    /          /|" << endl;
    cout << "   /          / |" << endl;
    cout << "  +----------+  |" << endl;
    cout << "  |          |  +" << endl;
    cout << "  |          | /" << endl;
    cout << "  |          |/" << endl;
    cout << "  +----------+" << endl;
}



/*
run:

     +----------+
    /          /|
   /          / |
  +----------+  |
  |          |  +
  |          | /
  |          |/
  +----------+

*/

 



answered 22 hours ago by avibootz

Related questions

...