Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Solution to Cuboid Problem
- URL: http://www.reddit.com/r/dailyprogrammer/comments/xq2ao/832012_challenge_85_intermediate_3d_cuboid/
- Date: 08/06/2012
- Author: BlueMelon
- */
- #include <iostream>
- using std::cin;
- using std::cout;
- void drawCuboid(int length,int height,int depth){
- cout <<"\nLength: " <<length << " Height: " << height << " Depth: " << depth << "\n\n";
- /*Draw Top Part*/
- for(int d=0; d<depth; d++){
- //whitespace
- for(int w=0; w < (depth-d); w++) cout << " ";
- // :
- for(int c=0; c < (length - 1); c++) cout << ":";
- // top right edge
- cout << "/";
- // +
- for(int p=0; p < d; p++) cout << "+";
- cout << "\n";
- }
- /*Draw Middle Part*/
- for(int m=0; m < (height-depth); m++){
- // #
- for(int w=0; w < length; w++) cout << "#";
- // +
- for(int p=0; p < depth; p++) cout << "+";
- cout << "\n";
- }
- /*Draw Bottom Part*/
- for(int b=0; b <= depth; b++){
- // #
- for(int w=0; w < length; w++) cout << "#";
- // +
- for(int p=0; p < (depth-b); p++) cout << "+";
- cout << "\n";
- }
- return;
- }
- int main(){
- int w,h,d = 0;
- cout << "Enter Width,Height,Depth: \n";
- cin >> w >> h >> d;
- cout << "\nHere is your cube, \n\n";
- drawCuboid(w,h,d);
- cout << "\n\nDone\n\n";
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment