Advertisement
mihnea101

Untitled

Dec 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int n,i,j,k,l;
  6.  
  7. int main()
  8. {
  9.  
  10.     cin >> n;
  11.     k=n-1;
  12.     l=1;
  13.  
  14.     for(i=1;i<=n;i++)
  15.     {
  16.         for(j=1;j<=k;j++)
  17.             cout << " ";
  18.         for(j=1;j<=l;j++)
  19.             cout << i;
  20.         cout << endl;
  21.         k--;
  22.         l+=2;
  23.     }
  24.  
  25.     k++;
  26.     l-=2;
  27.  
  28.     for(i=n-1;i>=1;i--)
  29.     {
  30.         k++;
  31.         l-=2;
  32.         for(j=1;j<=k;j++)
  33.             cout << " ";
  34.         for(j=1;j<=l;j++)
  35.             cout << i;
  36.         cout << endl;
  37.     }
  38.     return 0;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement