Advertisement
sellmmaahh

z20-samostalni rad 1

Mar 3rd, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cout <<"Unesite broj n: ";
  9.     do
  10.     {
  11.         cin >> n;
  12.     }
  13.     while(n < 5 || n > 24);
  14.  
  15.     for(int i = 0; i < n; i++)
  16.     {
  17.         if(i==0 || i==n-1)
  18.         {
  19.             cout<<"+";
  20.             for(int j=0; j<2*n; j++)
  21.             {
  22.                 cout<<"-";
  23.             }
  24.             cout<<"+";
  25.             cout<<endl;
  26.         }
  27.         else if(i ==1 || i==n-2)
  28.         {
  29.             cout<<"|";
  30.             for(int j=0; j<2*n; j++)
  31.             {
  32.                 cout<<" ";
  33.             }
  34.             cout<<"|";
  35.             cout<<endl;
  36.         }
  37.         else if(i==2 || i ==n-3)
  38.         {
  39.             cout<<"|  +";
  40.             for(int j=0; j<(2*(n-2))-2; j++)
  41.             {
  42.                 cout<<"-";
  43.             }
  44.             cout<<"+  |";
  45.             cout<<endl;
  46.         }
  47.         else
  48.         {
  49.             cout<<"|  |";
  50.             for(int j=0; j<(2*(n-2))-2; j++)
  51.             {
  52.                 cout<<" ";
  53.             }
  54.             cout<<"|  |";
  55.             cout<<endl;
  56.  
  57.         }
  58.     }
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement