Advertisement
Gireada

PCLP ROMB

Dec 16th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3.  
  4. int main()
  5. {
  6.     int a,i,j,d,z,n;
  7.     char c;
  8.     cout<<"Introdu numarul: ";cin>>a;
  9.     cout<<"Introdu caracterul :";cin>>c;
  10.     d = -1;
  11.     if(a%2 == 0)
  12.     a++;
  13.     for(i = 1; i<=a/2+1; i++)
  14.     {
  15.         d++;
  16.         cout<<endl;
  17.         for(j = 1; j<=a; j++)
  18.         {
  19.             if(j >= (a/2+1)-d && j <= (a/2+1)+d)
  20.                 cout<<c;
  21.             else
  22.                 cout<<" ";
  23.         }
  24.     }
  25.     d = a-1;
  26.    n = 0;
  27.     for(i = a/2; i >= 1; i--)
  28.     {
  29.         n++;
  30.         cout<<endl;
  31.         for(j = 1; j<=a; j++)
  32.         {
  33.             if(j<=d && j > n)
  34.                 cout<<c;
  35.             else
  36.                 cout<<" ";
  37.         }
  38.         d--;
  39.    }
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement