Advertisement
payjack

class example nestedloopbox

Nov 1st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. int getInput ()
  7.     {
  8.         cout<<"What size is the box?"<<endl;
  9.         int x;
  10.         cin>>x;
  11.         return x;
  12.  
  13.     }
  14.  
  15. int main ()
  16. {
  17.  
  18. int x = getInput ();
  19.  
  20.  
  21. for ( int i = 1; i <= x+2; i++ )
  22. {
  23.     for ( int j = 1; j=x; j++)
  24.     {
  25.         if ( i == 1 || i == (x+2) )
  26.             cout<<"+"<<endl;
  27.  
  28.         else {
  29.             cout<<"^"<<endl;
  30.  
  31.         if (j==(x+2))
  32.             cout<<endl;
  33.  
  34.             }
  35.     }
  36.  
  37.  
  38.  
  39.     {
  40.         for ( int m = 0; m <= x; m++ )
  41.         {
  42.             if ( m == 0 || m == (x+1) )
  43.                 cout<<"+";
  44.  
  45.         }
  46.                 {
  47.                     if ( (i>0) || (i<(x+1)) )
  48.                         cout<<"^";
  49.                 }
  50.  
  51.                 {
  52.                     if ( (m>0) || (m<(x+1)))
  53.                         cout<<"^";
  54.                 }
  55.     }
  56.     else
  57.         {
  58.             for ( int g = 0; g <= x; g++)
  59.                 if (g == 0 || (g == (x+1)))
  60.                 cout << "|";
  61.         }
  62.  
  63.         }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement